Module: Yasm::Persistence::CouchRest::Model::GetMethods

Defined in:
lib/yasm/persistence/couchrest_model.rb

Instance Method Summary collapse

Instance Method Details

#get_with_load_yasm_states(id, db = database) ⇒ Object Also known as: find_with_load_yasm_states



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/yasm/persistence/couchrest_model.rb', line 15

def get_with_load_yasm_states(id, db = database)
  doc = get_without_load_yasm_states id, db
  doc.class.state_configurations.keys.each do |state_name|
    Yasm::Manager.change_state(
      :to => doc["yasm"]["states"][state_name.to_s]["class"].to_sym.to_class,
      :on => doc.send(:state_container, state_name.to_sym), 
      :at => Time.parse(doc["yasm"]["states"][state_name.to_s]["instantiated_at"])
    )
  end if doc["yasm"] and doc["yasm"]["states"]
  doc.fast_forward
  doc
end