Skip to content

Instantly share code, notes, and snippets.

@lukesutton
Created December 13, 2008 01:35
Show Gist options
  • Select an option

  • Save lukesutton/35373 to your computer and use it in GitHub Desktop.

Select an option

Save lukesutton/35373 to your computer and use it in GitHub Desktop.
# Check types
def type_check(checks)
checks.each do |var, types|
types = types.is_a? Array ? types : [types]
match = false
types.each { |type| match = true if var.is_a? type }
raise ArgumentError unless match
end
end
# Usage
def self.localized_tree(locale, dialect, page_opts = {})
type_check(
locale => [Locale, Numeric],
dialect => [Dialect, Numeric],
page_opts => Hash
)
# Do some other stuff
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment