Class: Ecommerce::AttributeHandler
- Inherits:
-
Object
- Object
- Ecommerce::AttributeHandler
- Defined in:
- lib/ecommerce/attribute_handler.rb
Constant Summary collapse
- KINDS =
[:decimal, :date, :datetime]
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
Class Method Summary collapse
Instance Method Summary collapse
- #handle ⇒ Object
-
#initialize(attribute) ⇒ AttributeHandler
constructor
A new instance of AttributeHandler.
Constructor Details
#initialize(attribute) ⇒ AttributeHandler
Returns a new instance of AttributeHandler.
10 11 12 |
# File 'lib/ecommerce/attribute_handler.rb', line 10 def initialize(attribute) @attribute = attribute end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
8 9 10 |
# File 'lib/ecommerce/attribute_handler.rb', line 8 def attribute @attribute end |
Class Method Details
.handle(attribute) ⇒ Object
14 15 16 |
# File 'lib/ecommerce/attribute_handler.rb', line 14 def self.handle(attribute) self.new(attribute).handle end |
Instance Method Details
#handle ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ecommerce/attribute_handler.rb', line 18 def handle KINDS.each do |kind| return send("as_#{kind}") if send("is_#{kind}?") end attribute end |