Sha256: c4406c4ffd03bc533fd05932b9295a270aa9a01bcdaf641b985627ecfc402120
Contents?: true
Size: 683 Bytes
Versions: 11
Compression:
Stored size: 683 Bytes
Contents
require 'spyke/relation' require 'spyke/scope_registry' module Spyke module Scoping extend ActiveSupport::Concern module ClassMethods delegate :where, :build, :any?, :empty?, to: :all delegate :with, to: :all def all current_scope || Relation.new(self, uri: uri) end def scope(name, code) define_singleton_method name, code end def current_scope=(scope) ScopeRegistry.set_value_for(:current_scope, name, scope) end def current_scope ScopeRegistry.value_for(:current_scope, name) end end private def scope @scope ||= self.class.all end end end
Version data entries
11 entries across 11 versions & 1 rubygems