Module: Volt::StoreRootHelpers
- Defined in:
- lib/volt/models/root_models/store_root.rb
Instance Method Summary collapse
- #get(attr_name, expand = false) ⇒ Object
- #model_for_root ⇒ Object
- #set(attr_name, value, &block) ⇒ Object
Instance Method Details
#get(attr_name, expand = false) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/volt/models/root_models/store_root.rb', line 21 def get(attr_name, = false) res = if attr_name.singular? && attr_name.to_sym != :id puts "GET: #{attr_name}" model_for_root.get(attr_name, ) else super end # puts "GOT: #{res.inspect}" res end |
#model_for_root ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/volt/models/root_models/store_root.rb', line 11 def model_for_root root = nil Volt::Computation.run_without_tracking do root = get(:root_store_models).first_or_create end root end |
#set(attr_name, value, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/volt/models/root_models/store_root.rb', line 33 def set(attr_name, value, &block) if attr_name.singular? && attr_name.to_sym != :id puts "SET ATTR NAME: #{attr_name.inspect}: #{value.inspect}" Volt::Computation.run_without_tracking do model_for_root.then do |model| model.set(attr_name, value, &block) end end else super end # puts "SET---" end |