Sha256: d5327e2d197d064f74ae731567d1db89da75cd1747e57e80c3d573980b59dec5
Contents?: true
Size: 1.24 KB
Versions: 4
Compression:
Stored size: 1.24 KB
Contents
# StoreRoot should already be setup when this class is already loaded. It is a # Volt::Model that is loaded as the base class for the root of store. # # In order to support setting properties directly on store, we create a table # called "root_store_models", and create a single require 'volt/models/root_models/root_models' module Volt module StoreRootHelpers def model_for_root root = nil Volt::Computation.run_without_tracking do root = get(:root_store_models).first_or_create end root end def get(attr_name, expand = false) res = if attr_name.singular? && attr_name.to_sym != :id puts "GET: #{attr_name}" model_for_root.get(attr_name, expand) else super end # puts "GOT: #{res.inspect}" res end 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 end end # StoreRoot.send(:include, Volt::StoreRootHelpers)
Version data entries
4 entries across 4 versions & 1 rubygems