Module: CafeCar::OptionHelpers

Extended by:
ActiveSupport::Concern
Included in:
Presenter, Table::Builder
Defined in:
lib/cafe_car/option_helpers.rb

Instance Method Summary collapse

Instance Method Details

#assign_option!(k, default) ⇒ Object



16
17
18
19
# File 'lib/cafe_car/option_helpers.rb', line 16

def assign_option!(k, default)
  value = get_options.delete(k) { default.respond_to?(:call) ? default.call : default.clone }
  instance_variable_set("@#{k}", value)
end

#assign_options!Object



11
12
13
14
# File 'lib/cafe_car/option_helpers.rb', line 11

def assign_options!
  raise "@options is not a hash" unless get_options.is_a? Hash
  option_defaults.each { assign_option!(_1, _2) }
end

#get_optionsObject



9
# File 'lib/cafe_car/option_helpers.rb', line 9

def get_options = @options