Sha256: 2f0a4429a5bb2bebeaea83e410a5914e86e45d56c3956c90c0f6292feb9e6e9c
Contents?: true
Size: 1.29 KB
Versions: 12
Compression:
Stored size: 1.29 KB
Contents
class Eco::Data::Locations::NodeDiff module Accessors class << self def included(base) super(base) base.extend Eco::Language::Models::ClassHelpers base.extend ClassMethods base.inheritable_class_vars :exposed_attrs end end module ClassMethods # Creates the defined accessor attributes against `NodeDiff` # It also creates a method with question mark that evaluates true if **any** the attr changed. # @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]` 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 # Keeps track on what attributes have been exposed. def exposed_attrs @exposed_attrs ||= [] end end end end
Version data entries
12 entries across 12 versions & 1 rubygems