Module: Eco::Data::Locations::NodeDiff::Accessors::ClassMethods

Defined in:
lib/eco/data/locations/node_diff/accessors.rb

Instance Method Summary collapse

Instance Method Details

#attr_expose(*attrs) ⇒ Object

Note:

the defined attributes are expected to be the keys within the source Hashes that are being compared.

Note:

accessing src1 (prev) attributes, will have it's method as prev_[attrName]

Creates the defined accessor attributes against NodeDiff It also creates a method with question mark that evaluates true if any the attr changed.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/eco/data/locations/node_diff/accessors.rb', line 18

def attr_expose(*attrs)
  attrs.each do |attr|
    meth  = attr.to_sym
    methp = "prev_#{meth}".to_sym
    methq = "diff_#{meth}?".to_sym

    define_method meth do
      attr(meth)
    end

    define_method methp do
      attr_prev(meth)
    end

    exposed_attrs |= [meth]

    define_method methq do
      diff_attr?(meth)
    end
  end
end

#exposed_attrsObject

Keeps track on what attributes have been exposed.



41
42
43
# File 'lib/eco/data/locations/node_diff/accessors.rb', line 41

def exposed_attrs
  @exposed_attrs ||= []
end