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.



3
4
5
6
# File 'lib/active_graph/attribute_set.rb', line 3

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



8
9
10
11
12
13
14
# File 'lib/active_graph/attribute_set.rb', line 8

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



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

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

#keysObject



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

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

#respond_to_missing?(method) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/active_graph/attribute_set.rb', line 16

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