Class: Daywalker::DynamicFinderMatch

Inherits:
Object
  • Object
show all
Defined in:
lib/daywalker/dynamic_finder_match.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

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_namesObject

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

#finderObject

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

Returns:

  • (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