Module: XES::AttributeAccessor
- Included in:
- Attribute, EventAttributeAccessor, Log, TraceAttributeAccessor
- Defined in:
- lib/xes/attribute-accessor.rb
Overview
AttributeAccessor provides attribute accessors of standard extensions.
Instance Method Summary collapse
-
#define_attribute(name, type) ⇒ void
Define an attribute accessor.
Instance Method Details
#define_attribute(name, type) ⇒ void
This method returns an undefined value.
Define an attribute accessor.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/xes/attribute-accessor.rb', line 11 def define_attribute(name, type) _name = name.gsub(":", "_") define_method(_name) do var = instance_variables.include?(:@meta) ? :@meta : :@attributes instance_variable_get(var).find do |attribute| attribute.key == name end.tap{|x| return x.value if x} end define_method("%s=" % _name) do |value| var = instance_variables.include?(:@meta) ? :@meta : :@attributes instance_variable_get(var).tap do |attributes| if elt = __send__(_name) attributes.delete(elt) end attributes << XES.send(type, name, value) end end end |