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 |
# 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 model_for_root.get(attr_name, ) else super end 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
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/volt/models/root_models/store_root.rb', line 31 def set(attr_name, value, &block) if attr_name.singular? && attr_name.to_sym != :id 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 |