Module: Sandwich::Amounts

Defined in:
lib/sandwich/helpers/amounts.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/sandwich/helpers/amounts.rb', line 3

def method_missing(name, *args)
  if name.to_s =~ /amount=$/
    association = name.to_s.gsub("_amount=", "").pluralize
  
    if respond_to?(association)
      args.first.times { send(association).make }
    else
      super
    end
  else
    super
  end
end