Class: Ingenico::Connect::SDK::Domain::Metadata::ShoppingCartExtension
- Inherits:
-
Ingenico::Connect::SDK::DataObject
- Object
- Ingenico::Connect::SDK::DataObject
- Ingenico::Connect::SDK::Domain::Metadata::ShoppingCartExtension
- Defined in:
- lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb
Overview
Represents metadata part of shopping carts.
Instance Attribute Summary collapse
-
#creator ⇒ Object
readonly
Returns the value of attribute creator.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
-
.new_from_hash(hash) ⇒ Object
Constructs a new ShoppingCartExtension from parameter hash the hash should contain a creator, name and version – Overridden so ShoppingCartExtension can retain mandatory default arguments ++.
Instance Method Summary collapse
-
#from_hash(hash) ⇒ Object
loads shopping cart metadata from a parameter hash.
-
#initialize(creator, name, version) ⇒ ShoppingCartExtension
constructor
A new instance of ShoppingCartExtension.
-
#to_h ⇒ Object
Converts the shopping cart metadata to a hash.
Constructor Details
#initialize(creator, name, version) ⇒ ShoppingCartExtension
Returns a new instance of ShoppingCartExtension.
7 8 9 10 11 12 13 14 15 |
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 7 def initialize(creator, name, version) raise ArgumentError.new if creator.nil? or creator.strip.empty? raise ArgumentError.new if name.nil? or name.strip.empty? raise ArgumentError.new if version.nil? or version.to_s.strip.empty? @creator = creator @name = name @version = version.to_s end |
Instance Attribute Details
#creator ⇒ Object (readonly)
Returns the value of attribute creator.
46 47 48 |
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 46 def creator @creator end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
46 47 48 |
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 46 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
46 47 48 |
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 46 def version @version end |
Class Method Details
.new_from_hash(hash) ⇒ Object
Constructs a new ShoppingCartExtension from parameter hash the hash should contain a creator, name and version – Overridden so ShoppingCartExtension can retain mandatory default arguments ++
22 23 24 25 26 27 |
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 22 def self.new_from_hash(hash) creator = hash['creator'] if hash.has_key?('creator') name = hash['name'] if hash.has_key?('name') version = hash['version'] if hash.has_key?('version') self.new(creator, name, version) end |
Instance Method Details
#from_hash(hash) ⇒ Object
loads shopping cart metadata from a parameter hash
39 40 41 42 43 44 |
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 39 def from_hash(hash) super @creator = hash['creator'] if hash.has_key?('creator') @name = hash['name'] if hash.has_key?('name') @version = hash['version'] if hash.has_key?('version') end |
#to_h ⇒ Object
Converts the shopping cart metadata to a hash
30 31 32 33 34 35 36 |
# File 'lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb', line 30 def to_h hash = super add_to_hash(hash, 'creator', @creator) add_to_hash(hash, 'name', @name) add_to_hash(hash, 'version', @version) hash end |