Sha256: 274ada9e2b72c5f22c9d9ccbbcde938d8966ac6042dcac481f518e2f1fbd0487

Contents?: true

Size: 665 Bytes

Versions: 43

Compression:

Stored size: 665 Bytes

Contents

module ActiveGraph::Node
  module Enum
    extend ActiveSupport::Concern
    include ActiveGraph::Shared::Enum

    module ClassMethods
      protected

      def define_property(property_name, *args)
        super
        ActiveGraph::ModelSchema.add_required_index(self, property_name) unless args[1][:_index] == false
      end

      def define_enum_methods(property_name, enum_keys, options)
        super
        define_enum_scopes(property_name, enum_keys)
      end

      def define_enum_scopes(property_name, enum_keys)
        enum_keys.each_key do |name|
          scope name, -> { where(property_name => name) }
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
activegraph-12.0.0.beta.5 lib/active_graph/node/enum.rb
activegraph-12.0.0.beta.4 lib/active_graph/node/enum.rb
activegraph-11.5.0.beta.3 lib/active_graph/node/enum.rb
activegraph-12.0.0.beta.3 lib/active_graph/node/enum.rb
activegraph-12.0.0.beta.2 lib/active_graph/node/enum.rb
activegraph-11.5.0.beta.2 lib/active_graph/node/enum.rb
activegraph-12.0.0.beta.1 lib/active_graph/node/enum.rb
activegraph-11.5.0.beta.1 lib/active_graph/node/enum.rb
activegraph-11.5.0.alpha.1 lib/active_graph/node/enum.rb
activegraph-11.4.0 lib/active_graph/node/enum.rb
activegraph-11.3.1 lib/active_graph/node/enum.rb
activegraph-11.3.0 lib/active_graph/node/enum.rb
activegraph-11.2.0 lib/active_graph/node/enum.rb
activegraph-11.1.0 lib/active_graph/node/enum.rb
activegraph-11.1.0.beta.1 lib/active_graph/node/enum.rb
activegraph-11.1.0.alpha.4 lib/active_graph/node/enum.rb
activegraph-11.1.0.alpha.3 lib/active_graph/node/enum.rb
activegraph-11.1.0.alpha.2 lib/active_graph/node/enum.rb
activegraph-11.1.0.alpha.1 lib/active_graph/node/enum.rb
activegraph-10.2.0.beta.1 lib/active_graph/node/enum.rb