Module: Assert::View::Helpers::Common::ClassMethods

Defined in:
lib/assert/view/helpers/common.rb

Instance Method Summary collapse

Instance Method Details

#option(name, *default_vals) ⇒ Object



195
196
197
198
199
200
201
202
203
# File 'lib/assert/view/helpers/common.rb', line 195

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