Class: Looksy::DynamicFindMatch

Inherits:
Struct
  • Object
show all
Defined in:
lib/looksy/dynamic_find_match.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



2
3
4
# File 'lib/looksy/dynamic_find_match.rb', line 2

def attributes
  @attributes
end

#extractorObject

Returns the value of attribute extractor

Returns:

  • (Object)

    the current value of extractor



2
3
4
# File 'lib/looksy/dynamic_find_match.rb', line 2

def extractor
  @extractor
end

#finderObject

Returns the value of attribute finder

Returns:

  • (Object)

    the current value of finder



2
3
4
# File 'lib/looksy/dynamic_find_match.rb', line 2

def finder
  @finder
end

Class Method Details

.match(method) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/looksy/dynamic_find_match.rb', line 3

def self.match(method)
  finder = :find
  extractor = nil

  case method.to_s
  when /^find_(last_|all_)?by_([_a-zA-Z]\w*)$/
    case $1
    when 'last_'
      finder = :select
      extractor = :last
    when 'all_'
      finder = :select
    end

    attributes = $2
  else
    return nil
  end

  new(finder, extractor, attributes.split('_and_'))
end