Sha256: 524b4cf610907f02538909943f0175b69a006ef46a7b514cdedbb7ef95d9456a

Contents?: true

Size: 746 Bytes

Versions: 15

Compression:

Stored size: 746 Bytes

Contents

require 'active_support/concern'

module Ardm
  class Property
    module Flags
      extend ActiveSupport::Concern

      included do
        accept_options :flags
        attr_reader :flag_map

        class << self
          attr_accessor :generated_classes
        end

        self.generated_classes = {}
      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

15 entries across 15 versions & 1 rubygems

Version Path
ardm-0.4.0.ar427 lib/ardm/property/support/flags.rb
ardm-0.4.0 lib/ardm/property/support/flags.rb
ardm-0.3.2 lib/ardm/property/support/flags.rb
ardm-0.3.1 lib/ardm/property/support/flags.rb
ardm-0.3.0 lib/ardm/property/support/flags.rb
ardm-0.2.7 lib/ardm/property/support/flags.rb
ardm-0.2.6 lib/ardm/property/support/flags.rb
ardm-0.2.5 lib/ardm/property/support/flags.rb
ardm-0.2.4 lib/ardm/property/support/flags.rb
ardm-0.2.3 lib/ardm/property/support/flags.rb
ardm-0.2.2 lib/ardm/property/support/flags.rb
ardm-0.2.1 lib/ardm/property/support/flags.rb
ardm-0.2.0 lib/ardm/property/support/flags.rb
ardm-0.1.0 lib/ardm/property/support/flags.rb
ardm-0.0.1 lib/ardm/property/support/flags.rb