Sha256: e10d046a3e32ff5719c46b977df04e03a79aa42cb8d1b5ab6324f24419b4db48
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require 'active_data/model/collectionizable/proxy' module ActiveData module Model module Collectionizable extend ActiveSupport::Concern included do collectionize Array end module ClassMethods def collectionize collection_superclass = nil collection = Class.new(collection_superclass) do include ActiveData::Model::Collectionizable::Proxy end collection.collectible = self remove_const :Collection if const_defined? :Collection const_set :Collection, collection end def respond_to? method super || collection_class.superclass.method_defined?(method) end def method_missing method, *args, &block current_scope.send(method, *args, &block) if collection_class.superclass.method_defined?(method) end def collection source = nil collection_class.new source end def collection_class @collection_class ||= const_get(:Collection) end def current_scope= value @current_scope = value end def current_scope @current_scope ||= collection(load) end alias :scope :current_scope def load; end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_data-0.1.0 | lib/active_data/model/collectionizable.rb |