Class: Daywalker::DynamicFinderMatch
- Inherits:
-
Object
- Object
- Daywalker::DynamicFinderMatch
- Defined in:
- lib/daywalker/dynamic_finder_match.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#attribute_names ⇒ Object
Returns the value of attribute attribute_names.
-
#finder ⇒ Object
Returns the value of attribute finder.
Instance Method Summary collapse
-
#initialize(method) ⇒ DynamicFinderMatch
constructor
A new instance of DynamicFinderMatch.
- #match? ⇒ Boolean
Constructor Details
#initialize(method) ⇒ DynamicFinderMatch
Returns a new instance of DynamicFinderMatch.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/daywalker/dynamic_finder_match.rb', line 5 def initialize(method) case method.to_s when /^find_(all_by|by)_([_a-zA-Z]\w*)$/ @finder = case $1 when 'all_by' then :all when 'by' then :one end @attribute_names = $2.split('_and_').map {|each| each.to_sym} end end |
Instance Attribute Details
#attribute_names ⇒ Object
Returns the value of attribute attribute_names.
4 5 6 |
# File 'lib/daywalker/dynamic_finder_match.rb', line 4 def attribute_names @attribute_names end |
#finder ⇒ Object
Returns the value of attribute finder.
4 5 6 |
# File 'lib/daywalker/dynamic_finder_match.rb', line 4 def finder @finder end |
Instance Method Details
#match? ⇒ Boolean
16 17 18 19 20 |
# File 'lib/daywalker/dynamic_finder_match.rb', line 16 def match? @attribute_names && @attribute_names.all? do |each| Daywalker::Legislator::VALID_ATTRIBUTES.include? each end end |