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.
7 8 9 10 11 |
# File 'lib/friendly/scope_proxy.rb', line 7 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.
5 6 7 |
# File 'lib/friendly/scope_proxy.rb', line 5 def klass @klass end |
#scope_klass ⇒ Object (readonly)
Returns the value of attribute scope_klass.
5 6 7 |
# File 'lib/friendly/scope_proxy.rb', line 5 def scope_klass @scope_klass end |
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
5 6 7 |
# File 'lib/friendly/scope_proxy.rb', line 5 def scopes @scopes end |
Instance Method Details
#ad_hoc(parameters) ⇒ Object
26 27 28 |
# File 'lib/friendly/scope_proxy.rb', line 26 def ad_hoc(parameters) scope_klass.new(klass, parameters) end |
#add_named(name, parameters) ⇒ Object
13 14 15 16 |
# File 'lib/friendly/scope_proxy.rb', line 13 def add_named(name, parameters) scopes[name] = parameters add_scope_method_to_klass(name) end |
#get(name) ⇒ Object
18 19 20 |
# File 'lib/friendly/scope_proxy.rb', line 18 def get(name) scopes[name] end |
#get_instance(name) ⇒ Object
22 23 24 |
# File 'lib/friendly/scope_proxy.rb', line 22 def get_instance(name) scope_klass.new(klass, get(name)) end |
#has_named_scope?(name) ⇒ Boolean
30 31 32 |
# File 'lib/friendly/scope_proxy.rb', line 30 def has_named_scope?(name) scopes.has_key?(name) end |