Module: Windy::Finders

Included in:
Collection, PaginatedCollection
Defined in:
lib/windy.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/windy.rb', line 83

def method_missing(method, *args, &block)
  if attribute = method.to_s[/^(find(_all)?)_by_(.+)$/, 3]
    value = args.first
    send($1) { |record| record.send(attribute) == value }
  else
    super
  end
end

Instance Method Details

#[](index) ⇒ Object



75
76
77
# File 'lib/windy.rb', line 75

def [](index)
  to_a[index]
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/windy.rb', line 79

def respond_to?(method)
  method.to_s[/^find(_all)?_by_./] || super
end