Class: Spree::TestingSupport::Microdata::Item
- Inherits:
-
Object
- Object
- Spree::TestingSupport::Microdata::Item
- Defined in:
- lib/spree/testing_support/microdata.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(top_node) ⇒ Item
constructor
A new instance of Item.
- #to_hash ⇒ Object
Constructor Details
#initialize(top_node) ⇒ Item
Returns a new instance of Item.
26 27 28 29 30 31 32 33 |
# File 'lib/spree/testing_support/microdata.rb', line 26 def initialize(top_node) @top_node = top_node @type = extract_item_type @id = extract_item_id @properties = {} add_item_ref_properties(@top_node) parse_elements(extract_elements(@top_node)) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
24 25 26 |
# File 'lib/spree/testing_support/microdata.rb', line 24 def id @id end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
24 25 26 |
# File 'lib/spree/testing_support/microdata.rb', line 24 def properties @properties end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
24 25 26 |
# File 'lib/spree/testing_support/microdata.rb', line 24 def type @type end |
Instance Method Details
#to_hash ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/spree/testing_support/microdata.rb', line 35 def to_hash hash = {} hash[:id] = id if id hash[:type] = type if type hash[:properties] = {} properties.each do |name, values| final_values = values.map do |value| if value.reponds_to?(:to_hash) value.to_hash else value end end hash[:properties][name] = final_values end hash end |