Class: Friendly::ScopeProxy
- Inherits:
-
Object
- Object
- Friendly::ScopeProxy
- Defined in:
- lib/friendly/scope_proxy.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#scope_klass ⇒ Object
readonly
Returns the value of attribute scope_klass.
-
#scopes ⇒ Object
readonly
Returns the value of attribute scopes.
Instance Method Summary collapse
- #ad_hoc(parameters) ⇒ Object
- #add_named(name, parameters) ⇒ Object
- #get(name) ⇒ Object
- #get_instance(name) ⇒ Object
- #has_named_scope?(name) ⇒ Boolean
-
#initialize(klass, scope_klass = Scope) ⇒ ScopeProxy
constructor
A new instance of ScopeProxy.
Constructor Details
#initialize(klass, scope_klass = Scope) ⇒ ScopeProxy
Returns a new instance of ScopeProxy.
5 6 7 8 9 |
# File 'lib/friendly/scope_proxy.rb', line 5 def initialize(klass, scope_klass = Scope) @klass = klass @scope_klass = scope_klass @scopes = {} end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/friendly/scope_proxy.rb', line 3 def klass @klass end |
#scope_klass ⇒ Object (readonly)
Returns the value of attribute scope_klass.
3 4 5 |
# File 'lib/friendly/scope_proxy.rb', line 3 def scope_klass @scope_klass end |
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
3 4 5 |
# File 'lib/friendly/scope_proxy.rb', line 3 def scopes @scopes end |
Instance Method Details
#ad_hoc(parameters) ⇒ Object
24 25 26 |
# File 'lib/friendly/scope_proxy.rb', line 24 def ad_hoc(parameters) scope_klass.new(klass, parameters) end |
#add_named(name, parameters) ⇒ Object
11 12 13 14 |
# File 'lib/friendly/scope_proxy.rb', line 11 def add_named(name, parameters) scopes[name] = parameters add_scope_method_to_klass(name) end |
#get(name) ⇒ Object
16 17 18 |
# File 'lib/friendly/scope_proxy.rb', line 16 def get(name) scopes[name] end |
#get_instance(name) ⇒ Object
20 21 22 |
# File 'lib/friendly/scope_proxy.rb', line 20 def get_instance(name) scope_klass.new(klass, get(name)) end |
#has_named_scope?(name) ⇒ Boolean
28 29 30 |
# File 'lib/friendly/scope_proxy.rb', line 28 def has_named_scope?(name) scopes.has_key?(name) end |