Skip to content

Instantly share code, notes, and snippets.

@jamtur01
Created March 11, 2013 14:20
Show Gist options
  • Save jamtur01/5134563 to your computer and use it in GitHub Desktop.
Save jamtur01/5134563 to your computer and use it in GitHub Desktop.
Boolean in types
# Processes the options for a named parameter.
# @param name [String] the name of a parameter
# @param options [Hash] a hash of options
# @option options [Boolean] :boolean if option set to true, an access method on the form _name_? is added for the param
# @return [void]
#
def self.handle_param_options(name, options)
# If it's a boolean parameter, create a method to test the value easily
if options[:boolean]
define_method(name.to_s + "?") do
val = self[name]
if val == :true or val == true
return true
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment