Module: Assert::ViewHelpers::ClassMethods

Defined in:
lib/assert/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#option(name, *default_vals) ⇒ Object


16
17
18
19
20
21
22
23
24
# File 'lib/assert/view_helpers.rb', line 16

def option(name, *default_vals)
  default = default_vals.size > 1 ? default_vals : default_vals.first
  define_method(name) do |*args|
    unless (value = args.size > 1 ? args : args.first).nil?
      instance_variable_set("@#{name}", value)
    end
    (val = instance_variable_get("@#{name}")).nil? ? default : val
  end
end