class Whowas::MySearchMethod
Private Instance Methods
format_input(input)
click to toggle source
Search method-wide transformations to the input. For example, if all mac addresses given as input to this search method should use colons as separators, perform that transformation here.
Adapter-wide transformations to the input can be made in the adapter format method.
# File lib/generators/whowas/templates/search_method.rb, line 50 def format_input(input) input end
input_formats()
click to toggle source
Validates the values of required inputs. This should be a hash containing the required input as key, and a lambda taking input and returning a boolean as value.
# File lib/generators/whowas/templates/search_method.rb, line 36 def input_formats { # timestamp: lambda { |input| DateTime.parse(input) && true rescue false } } end
output_formats()
click to toggle source
Extract pieces of the results string from the adapter using regex to form the input hash for the next search method or the final result.
# File lib/generators/whowas/templates/search_method.rb, line 58 def output_formats { # username: /User <\K\w*/ } end
required_inputs()
click to toggle source
Defines required elements of the input hash. This should be an array containing the required inputs as symbols.
# File lib/generators/whowas/templates/search_method.rb, line 26 def required_inputs [ # :ip, # :timestamp ] end