Class: Shokkenki::Consumer::Model::Interaction
- Inherits:
-
Object
- Object
- Shokkenki::Consumer::Model::Interaction
- Defined in:
- lib/shokkenki/consumer/model/interaction.rb
Instance Attribute Summary collapse
-
#fixtures ⇒ Object
readonly
Returns the value of attribute fixtures.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Interaction
constructor
A new instance of Interaction.
- #to_hash ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Interaction
Returns a new instance of Interaction.
10 11 12 13 14 15 16 |
# File 'lib/shokkenki/consumer/model/interaction.rb', line 10 def initialize attributes @request = attributes[:request].to_shokkenki_term @label = attributes[:label] || attributes[:request].label @response = attributes[:response].to_shokkenki_term @fixtures = attributes[:fixtures] @time = Time.now end |
Instance Attribute Details
#fixtures ⇒ Object (readonly)
Returns the value of attribute fixtures.
8 9 10 |
# File 'lib/shokkenki/consumer/model/interaction.rb', line 8 def fixtures @fixtures end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
8 9 10 |
# File 'lib/shokkenki/consumer/model/interaction.rb', line 8 def label @label end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
8 9 10 |
# File 'lib/shokkenki/consumer/model/interaction.rb', line 8 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
8 9 10 |
# File 'lib/shokkenki/consumer/model/interaction.rb', line 8 def response @response end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
8 9 10 |
# File 'lib/shokkenki/consumer/model/interaction.rb', line 8 def time @time end |
Instance Method Details
#to_hash ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/shokkenki/consumer/model/interaction.rb', line 18 def to_hash hash = { :request => @request.to_hash, :response => @response.to_hash, :time => @time.utc.iso8601, :label => @label } hash.merge!(:fixtures => @fixtures.map{ |f| f.to_hash }) if @fixtures hash end |