Sha256: 29f6340c0f390bc7b59be1dfb7f292d311439ab143da5ae933a0c91a331b2c6b

Contents?: true

Size: 436 Bytes

Versions: 8

Compression:

Stored size: 436 Bytes

Contents

module ActiveRecord
  module Enumerations
    class EnumBlock    
      def initialize enum_class, options = {}
        @enums = []
        @last_id = 0
        @enum_class = enum_class
        @options = options
      end
    
      def method_missing method, args = {}
        attrs = @options.merge(args).merge(:name => method)
        attrs[:id] ||= @last_id += 1
        @enums << @enum_class.new(attrs)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ar-enums-1.0.0 lib/ar_enums/enum_block.rb
ar-enums-0.3.9 lib/ar_enums/enum_block.rb
ar-enums-0.3.8 lib/ar_enums/enum_block.rb
ar-enums-0.3.7 lib/ar_enums/enum_block.rb
ar-enums-0.3.6 lib/ar_enums/enum_block.rb
ar-enums-0.3.5 lib/ar_enums/enum_block.rb
ar-enums-0.3.4 lib/enum_block.rb
ar-enums-0.3.3 lib/enum_block.rb