Skip to content

Instantly share code, notes, and snippets.

@jamtur01
Created March 11, 2013 14:20

Revisions

  1. jamtur01 created this gist Mar 11, 2013.
    18 changes: 18 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@

    # 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