Sha256: 52cc15d5ef9b43b23bb71084c5a8491178a5f5d337873c0f956730273b44e53f

Contents?: true

Size: 834 Bytes

Versions: 13

Compression:

Stored size: 834 Bytes

Contents

module DataMapper
  class Property
    module Flags
      def self.included(base)
        base.class_eval <<-RUBY, __FILE__, __LINE__ + 1
          extend DataMapper::Property::Flags::ClassMethods

          accept_options :flags
          attr_reader :flag_map

          class << self
            attr_accessor :generated_classes
          end

          self.generated_classes = {}
        RUBY
      end

      def custom?
        true
      end

      module ClassMethods
        # TODO: document
        # @api public
        def [](*values)
          if klass = generated_classes[values.flatten]
            klass
          else
            klass = ::Class.new(self)
            klass.flags(values)

            generated_classes[values.flatten] = klass

            klass
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
ardm-types-1.2.3 lib/dm-types/support/flags.rb
ardm-types-1.2.2 lib/dm-types/support/flags.rb
dm-types-1.2.2 lib/dm-types/support/flags.rb
dm-types-1.2.1 lib/dm-types/support/flags.rb
dm-types-1.2.0 lib/dm-types/support/flags.rb
dm-types-1.2.0.rc2 lib/dm-types/support/flags.rb
dm-types-1.2.0.rc1 lib/dm-types/support/flags.rb
dm-types-1.1.0 lib/dm-types/support/flags.rb
dm-types-1.1.0.rc3 lib/dm-types/support/flags.rb
dm-types-1.1.0.rc2 lib/dm-types/support/flags.rb
dm-types-1.1.0.rc1 lib/dm-types/support/flags.rb
dm-types-1.0.2 lib/dm-types/support/flags.rb
dm-types-1.0.1 lib/dm-types/support/flags.rb