oleander / dry-interface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dry::Interface Main

require "dry/interface"

class Animal < Dry::Interface
  class Mammal < Concrete
    attribute :id, Value(:mammal)
  end

  class Bird < Value
    attribute :id, Value(:bird)
  end

  class Fish < Abstract
    class Whale < Value
      attribute :id, Value(:whale)
    end

    class Shark < Value
      attribute :id, Value(:shark)
    end
  end
end

Animal.new(id: :mammal) # => Animal::Mammal
Animal.new(id: :shark) # => Animal::Fish::Shark

About

License:MIT License


Languages

Language:Ruby 99.8%Language:Shell 0.2%