Module: Babushka::AcceptsValueFor

Included in:
DepDefiner
Defined in:
lib/babushka/accepts_value_for.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


3
4
5
# File 'lib/babushka/accepts_value_for.rb', line 3

def self.included base
  base.send :extend, ClassMethods
end

Instance Method Details

#store_value_for(method_name, data, choose_with) ⇒ Object


14
15
16
17
18
# File 'lib/babushka/accepts_value_for.rb', line 14

def store_value_for method_name, data, choose_with
  raise "Multiple values for #{method_name}" if data.respond_to?(:length) && data.length > 1
  payload.delete(method_name) # otherwise new values would be #concat'ed and ignored.
  store_list_for method_name, data, choose_with
end

#value_for(method_name, default) ⇒ Object


20
21
22
# File 'lib/babushka/accepts_value_for.rb', line 20

def value_for method_name, default
  list_for(method_name, default).first
end