Class: Io::Flow::V0::Models::Attribute
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Attribute
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
An attribute can be configured to be used in different ways throughout Flow. A common example is to identify a meaningful attribute (e.g. brand) that can then be displayed throughout the Flow console.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Attribute
constructor
A new instance of Attribute.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Attribute
Returns a new instance of Attribute.
6738 6739 6740 6741 6742 6743 6744 6745 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6738 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :key, :options], 'Attribute') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String) = (x = opts.delete(:options); x.is_a?(::Io::Flow::V0::Models::Options) ? x : ::Io::Flow::V0::Models::Options.new(x)) @label = (x = opts.delete(:label); x.nil? ? nil : HttpClient::Preconditions.assert_class('label', x, String)) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6736 6737 6738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6736 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
6736 6737 6738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6736 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
6736 6737 6738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6736 def label @label end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6736 6737 6738 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6736 def end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
6751 6752 6753 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6751 def copy(incoming={}) Attribute.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
6755 6756 6757 6758 6759 6760 6761 6762 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6755 def to_hash { :id => id, :key => key, :options => .to_hash, :label => label } end |
#to_json ⇒ Object
6747 6748 6749 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6747 def to_json JSON.dump(to_hash) end |