Sha256: ed786f59d3c71c3d64f299ea4acefb987ded9e89caf172bd4e2c97a4b953c9c8
Contents?: true
Size: 848 Bytes
Versions: 1
Compression:
Stored size: 848 Bytes
Contents
require 'active_support/concern' module ActiveHouse module Scopeable extend ActiveSupport::Concern included do private def apply_scope(name) scope = model_class._scopes.fetch(name.to_sym) instance_exec(*args, &scope) end def scope?(name) model_class._scopes.key?(name.to_sym) end def apply_default_scope return if model_class._default_scope.nil? apply_scope(model_class._default_scope) end end def initialize(*) super with_current_query { apply_default_scope } end def respond_to_missing?(method_name, *_args) scope?(method_name) || super end def method_missing(method_name, *args, &_block) if scope?(method_name) apply_scope(method_name) else super end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_house-0.1.3 | lib/active_house/scopeable.rb |