Class: ActiveGraph::AttributeSet

Inherits:
ActiveModel::AttributeSet
  • Object
show all
Defined in:
lib/active_graph/attribute_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(attr_hash, attr_list) ⇒ AttributeSet

Returns a new instance of AttributeSet.


7
8
9
10
# File 'lib/active_graph/attribute_set.rb', line 7

def initialize(attr_hash, attr_list)
  hashmap = ActiveGraph::LazyAttributeHash.new(attr_hash, attr_list)
  super(hashmap)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **kwargs, &block) ⇒ Object


12
13
14
15
16
17
18
# File 'lib/active_graph/attribute_set.rb', line 12

def method_missing(name, *args, **kwargs, &block)
  if defined?(name)
    attributes.send(:materialize).send(name, *args, **kwargs, &block)
  else
    super
  end
end

Instance Method Details

#==(other) ⇒ Object


28
29
30
# File 'lib/active_graph/attribute_set.rb', line 28

def ==(other)
  other.is_a?(ActiveGraph::AttributeSet) ? super : to_hash == other
end

#keysObject


24
25
26
# File 'lib/active_graph/attribute_set.rb', line 24

def keys
  attributes.send(:materialize).keys
end

#respond_to_missing?(method) ⇒ Boolean

Returns:

  • (Boolean)

20
21
22
# File 'lib/active_graph/attribute_set.rb', line 20

def respond_to_missing?(method, *)
  attributes.send(:materialize).respond_to?(method) || super
end