class Flowlink::ObjectBase
Attributes
f_methods[RW]
Base class for any Flowlink
objects. Children should implement self.fields internally.
Public Class Methods
fields()
click to toggle source
# File lib/flowlink_data/objectbase.rb, line 26 def self.fields # A list of fields that the object should have. fail NotImplementedError end
new(*overrides)
click to toggle source
# File lib/flowlink_data/objectbase.rb, line 10 def initialize(*overrides) unless overrides.flatten!.all? { |arg| arg.is_a?(FieldMethod) } # using array arguments isn't supported anymore fail ArgumentError, 'Arguments need to be FieldMethods' end defaults = FieldMethod.multi_new(fields) @f_methods = FieldMethod.merge(overrides, defaults) end
Public Instance Methods
fields()
click to toggle source
# File lib/flowlink_data/objectbase.rb, line 31 def fields @fields ||= self.class.fields end
to_hash()
click to toggle source
# File lib/flowlink_data/objectbase.rb, line 20 def to_hash Hash[@f_methods.map { |fm| [fm.method_name.to_s, fm.send_to(self)] }] end
Also aliased as: to_message