Class: Stall::Shipping::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/stall/shipping/config.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/stall/shipping/config.rb', line 18

def method_missing(name, *args)
  if (calculator = Stall::Shipping::Calculator.for(name))
    if block_given?
      yield calculator
    else
      calculator
    end
  else
    super
  end
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



14
15
16
# File 'lib/stall/shipping/config.rb', line 14

def configure
  yield self
end

#register_calculator(name, calculator) ⇒ Object

This mehtod allows for registering an in-app calculator that can be auto loaded without having to explicitly require it

Use a string representing the calculator name if the target class is auto-loaded by Rails



10
11
12
# File 'lib/stall/shipping/config.rb', line 10

def register_calculator(name, calculator)
  Stall::Shipping.calculators[name] = calculator
end