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.
-
#intent ⇒ Object
readonly
Returns the value of attribute intent.
-
#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.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
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.
14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14181 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) @options = (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)) @intent = (x = opts.delete(:intent); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::AttributeIntent) ? x : ::Io::Flow::V0::Models::AttributeIntent.apply(x))) @type = (x = opts.delete(:type); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::AttributeDataType) ? x : ::Io::Flow::V0::Models::AttributeDataType.apply(x))) @position = (x = opts.delete(:position); x.nil? ? nil : HttpClient::Preconditions.assert_class('position', x, Integer)) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
14179 14180 14181 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14179 def id @id end |
#intent ⇒ Object (readonly)
Returns the value of attribute intent.
14179 14180 14181 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14179 def intent @intent end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
14179 14180 14181 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14179 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
14179 14180 14181 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14179 def label @label end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14179 14180 14181 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14179 def @options end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
14179 14180 14181 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14179 def position @position end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
14179 14180 14181 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14179 def type @type end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
14197 14198 14199 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14197 def copy(incoming={}) Attribute.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14201 def to_hash { :id => id, :key => key, :options => .to_hash, :label => label, :intent => intent.nil? ? nil : intent.value, :type => type.nil? ? nil : type.value, :position => position } end |
#to_json ⇒ Object
14193 14194 14195 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14193 def to_json JSON.dump(to_hash) end |