Class: OfficeClerk::ShippingMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/office_clerk/shipping_method.rb

Direct Known Subclasses

Pickup

Constant Summary collapse

@@methods =
nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ShippingMethod

Returns a new instance of ShippingMethod.



3
4
5
6
7
8
# File 'lib/office_clerk/shipping_method.rb', line 3

def initialize data
  @data = data
  @name = @data[:name]
  @type = @data[:type]
  @description = @data[:description]
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/office_clerk/shipping_method.rb', line 9

def data
  @data
end

#descriptionObject (readonly)

Returns the value of attribute description.



9
10
11
# File 'lib/office_clerk/shipping_method.rb', line 9

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/office_clerk/shipping_method.rb', line 9

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/office_clerk/shipping_method.rb', line 9

def type
  @type
end

Class Method Details

.allObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/office_clerk/shipping_method.rb', line 15

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
      @@methods[key] = clas.new( method.merge(:type => key) )
    rescue
      puts "No such Class #{method[:class]}, check config.yml"
    end
  end
  @@methods
end

Instance Method Details

#price_for(basket) ⇒ Object



11
12
13
# File 'lib/office_clerk/shipping_method.rb', line 11

def price_for(basket)
  raise "Not implemented in #{self}"
end