class OfficeClerk::ShippingMethod

Attributes

data[R]
description[R]
name[R]
type[R]

Public Class Methods

all() click to toggle source
# File lib/office_clerk/shipping_method.rb, line 23
def self.all
  return @@methods if @@methods 
  @@methods = {}
  config = OfficeClerk.config(:shipping)
  config.each do |key , method|
    begin
      clas_name = method[:class]
      clas = clas_name.constantize
    rescue
      puts "No such Class #{method[:class]}, check config.yml"
    end
    @@methods[key] = clas.new( method.merge(:type => key) )
  end
  @@methods
end
method(name) click to toggle source
# File lib/office_clerk/shipping_method.rb, line 38
def self.method(name)
  return self.all.values.first if name.nil?
  m = self.all[name.to_sym]
  m.blank? ?  self.all.values.first : m
end
new(data) click to toggle source
# File lib/office_clerk/shipping_method.rb, line 3
def initialize data
  @data = data
  @name = @data[:name]
  @type = @data[:type]
  @description = @data[:description]
end

Public Instance Methods

available?(basket) click to toggle source
# File lib/office_clerk/shipping_method.rb, line 17
def available?(basket)
  true
end
price_for(basket) click to toggle source

the relevant interface for a shipping method is a) whether it applies to the order (basket) : available? b) how much sendin costs, price_for(basket)

# File lib/office_clerk/shipping_method.rb, line 14
def price_for(basket)
  raise "Not implemented in #{self}"
end