Class: ChargifyApi::List

Inherits:
Array
  • Object
show all
Defined in:
lib/list.rb

Instance Method Summary collapse

Instance Method Details

#search(search_method, search_term) ⇒ Object

List#search performs a search on each object in the list :search_method is the attribute or method you want to search (eg: :name) :search_term is the term you want to search for (eg: ‘Josh’) Search term can be a regular expresion or a string. Search method must be a method or attribute of the objects in the collection or an undefined method error will be raised.



8
9
10
# File 'lib/list.rb', line 8

def search(search_method, search_term)
  self.select { |list_item| list_item.send(search_method) =~ /#{search_term}/i }
end