class WhizClient::DynamicFinderMatch
Attributes
arguments[RW]
first_attribute[RW]
last_attribute[RW]
Public Class Methods
new(method_sym, arguments)
click to toggle source
# File lib/whiz_client.rb, line 34 def initialize(method_sym, arguments) if method_sym.to_s =~ /^find_(.*)_by_(.*)$/ @first_attribute = $1 @last_attribute = $2 @arguments = arguments elsif method_sym.to_s =~ /^list_all_(.*)$/ @first_attribute = $1 @arguments = arguments end end
Public Instance Methods
match?()
click to toggle source
# File lib/whiz_client.rb, line 45 def match? @first_attribute != nil || @last_attribute != nil end
params()
click to toggle source
# File lib/whiz_client.rb, line 49 def params if last_attribute.nil? params_with_single_attribute else params_with_multiple_attibutes end end
Private Instance Methods
argument()
click to toggle source
# File lib/whiz_client.rb, line 59 def argument arguments.first end
params_for_cities()
click to toggle source
# File lib/whiz_client.rb, line 83 def params_for_cities if last_attribute == 'state' { stateid: argument, method_name: 'indian-city-by-state' } elsif last_attribute == 'std_codes' { std_code: argument, method_name: 'city-from-std-codes' } elsif last_attribute == 'postal_code' { postal_code: argument, method_name: 'indian-city-by-postal-code' } end end
params_with_multiple_attibutes()
click to toggle source
# File lib/whiz_client.rb, line 71 def params_with_multiple_attibutes if first_attribute == 'city' params_for_cities elsif first_attribute == 'std_codes' && last_attribute == 'location' { location: argument, method_name: 'indian-std-codes' } elsif first_attribute == 'postal_code' && last_attribute == 'location' { location: argument, method_name: 'indian-postal-codes' } elsif first_attribute == 'current_time' && last_attribute == 'timezone' { time_zone: argument, method_name: 'current-time-of-timezone' } end end
params_with_single_attribute()
click to toggle source
# File lib/whiz_client.rb, line 63 def params_with_single_attribute if first_attribute == 'states' { method_name: 'indian-states-list' } elsif first_attribute == 'time_zones' { method_name: 'time-zones' } end end