Created
March 11, 2013 14:20
-
-
Save jamtur01/5134563 to your computer and use it in GitHub Desktop.
Boolean in types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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