class Flor::FlorModel
Attributes
Public Class Methods
Source
# File lib/flor/unit/models.rb, line 104 def from_h(h) cols = columns h .inject({}) { |r, (k, v)| k = k.to_sym if k == :data r[:content] = Flor.to_blob(v) elsif cols.include?(k) r[k] = v end r } end
Public Instance Methods
Source
# File lib/flor/unit/models.rb, line 68 def data(cache=true) cache ? (@flor_model_cache_data = _data) : _data end
Source
# File lib/flor/unit/models.rb, line 42 def execution(reload=false) exid = @values[:exid]; return nil unless exid @flor_model_cache_execution = nil if reload @flor_model_cache_execution ||= unit.executions[exid: exid] end
Return a Flor::Execution
instance linked to this model
Source
# File lib/flor/unit/models.rb, line 53 def node(reload=false) nid = @values[:nid]; return nil unless nid exe = execution(reload); return nil unless exe nodes = exe.data['nodes']; return nil unless nodes nodes[nid] end
Returns the node hash linked to this model
Source
# File lib/flor/unit/models.rb, line 62 def payload(reload=false) nod = node(reload) nod ? nod['payload'] : nil end
Source
# File lib/flor/unit/models.rb, line 73 def refresh instance_variables .each do |k| instance_variable_set(k, nil) \ if k.to_s.start_with?('@flor_model_cache_') end super end
Calls superclass method
Source
# File lib/flor/unit/models.rb, line 84 def to_h values.inject({}) do |h, (k, v)| if k == :content h[:data] = data else h[k] = v end h end end
Also aliased as: to_dump_h
Protected Instance Methods
Source
# File lib/flor/unit/models.rb, line 122 def _data d = Flor::Storage.from_blob(content) d['id'] = id if d.is_a?(Hash) d end