Module: EnumField::DefineEnum

Defined in:
lib/enum_field/define_enum.rb

Instance Method Summary collapse

Instance Method Details

#define_enum {|@enum_builder| ... } ⇒ Object

Yields:

  • (@enum_builder)


3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/enum_field/define_enum.rb', line 3

def define_enum(&block)
  @enum_builder ||= EnumField::Builder.new(self)
  yield @enum_builder

  [:all, :names, :find_by_id, :find, :first, :last].each do |method|
    instance_eval <<-END
      def #{method}(*args, &block)
        @enum_builder.send(:#{method}, *args, &block)
      end
    END
  end
end