Sha256: 14db67907ef10751e1cd9581f043dc516129974ee68eb47598b2c75334ab1fce
Contents?: true
Size: 944 Bytes
Versions: 71
Compression:
Stored size: 944 Bytes
Contents
module Concerns module Storable extend ActiveSupport::Concern included do has_many :stores, as: :storable, dependent: :destroy after_save do @store_collections.keys.each { |c| store(c).save } if @store_collections end end def storable? true end def store(collection = :default) @store_collections = {} unless @store_collections unless @store_collections[collection.to_sym] @store_collections[collection.to_sym] = Concerns::Storable::Collection.new( self, collection, self.class.store_config ) end @store_collections[collection.to_sym] end module ClassMethods def storable_field(name, type, default = nil) delegate name, "#{name}=", to: :store store_config.add name, type, default end def store_config @store_config ||= Concerns::Storable::Config.new end end end end
Version data entries
71 entries across 71 versions & 1 rubygems