module ZendeskAppsSupport::Finders
Public Instance Methods
find_by(arg)
click to toggle source
# File lib/zendesk_apps_support/finders.rb, line 11 def find_by(arg) all.find(&filter_by_arg(arg)) end
find_by!(arg)
click to toggle source
# File lib/zendesk_apps_support/finders.rb, line 15 def find_by!(arg) found = find_by(arg) raise(RecordNotFound, "Unable to find #{name} with #{arg.inspect}") if found.nil? found end
where(arg)
click to toggle source
# File lib/zendesk_apps_support/finders.rb, line 21 def where(arg) all.select(&filter_by_arg(arg)) end
Private Instance Methods
filter_by_arg(arg)
click to toggle source
# File lib/zendesk_apps_support/finders.rb, line 27 def filter_by_arg(arg) lambda do |findable_record| arg.all? do |attribute, value| value = value.to_s if value.is_a? Symbol findable_record.public_send(attribute) == value end end end