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
permalink #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
permalink #klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/friendly/scope_proxy.rb', line 3 def klass @klass end |
permalink #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 |
permalink #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
permalink #ad_hoc(parameters) ⇒ Object
[View source]
24 25 26 |
# File 'lib/friendly/scope_proxy.rb', line 24 def ad_hoc(parameters) scope_klass.new(klass, parameters) end |
permalink #add_named(name, parameters) ⇒ Object
[View source]
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 |
permalink #get(name) ⇒ Object
[View source]
16 17 18 |
# File 'lib/friendly/scope_proxy.rb', line 16 def get(name) scopes[name] end |
permalink #get_instance(name) ⇒ Object
[View source]
20 21 22 |
# File 'lib/friendly/scope_proxy.rb', line 20 def get_instance(name) scope_klass.new(klass, get(name)) end |
permalink #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 |