Class: OfficeClerk::ShippingMethod
- Inherits:
-
Object
- Object
- OfficeClerk::ShippingMethod
- Defined in:
- lib/office_clerk/shipping_method.rb
Direct Known Subclasses
Constant Summary collapse
- @@methods =
nil
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ ShippingMethod
constructor
A new instance of ShippingMethod.
- #price_for(basket) ⇒ Object
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
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/office_clerk/shipping_method.rb', line 9 def data @data end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
9 10 11 |
# File 'lib/office_clerk/shipping_method.rb', line 9 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/office_clerk/shipping_method.rb', line 9 def name @name end |
#type ⇒ Object (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
.all ⇒ Object
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 |