Class: ActiveRecord::DynamicScopeMatch
- Inherits:
-
Object
- Object
- ActiveRecord::DynamicScopeMatch
- Defined in:
- lib/active_record/dynamic_scope_match.rb
Instance Attribute Summary collapse
-
#attribute_names ⇒ Object
readonly
Returns the value of attribute attribute_names.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method) ⇒ DynamicScopeMatch
constructor
A new instance of DynamicScopeMatch.
- #scope? ⇒ Boolean
Constructor Details
#initialize(method) ⇒ DynamicScopeMatch
Returns a new instance of DynamicScopeMatch.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/active_record/dynamic_scope_match.rb', line 8 def initialize(method) @scope = true case method.to_s when /^scoped_by_([_a-zA-Z]\w*)$/ names = $1 else @scope = nil end @attribute_names = names && names.split('_and_') end |
Instance Attribute Details
#attribute_names ⇒ Object (readonly)
Returns the value of attribute attribute_names.
19 20 21 |
# File 'lib/active_record/dynamic_scope_match.rb', line 19 def attribute_names @attribute_names end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
19 20 21 |
# File 'lib/active_record/dynamic_scope_match.rb', line 19 def scope @scope end |
Class Method Details
.match(method) ⇒ Object
3 4 5 6 |
# File 'lib/active_record/dynamic_scope_match.rb', line 3 def self.match(method) ds_match = self.new(method) ds_match.scope ? ds_match : nil end |
Instance Method Details
#scope? ⇒ Boolean
21 22 23 |
# File 'lib/active_record/dynamic_scope_match.rb', line 21 def scope? !@scope.nil? end |