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