Class: Attune::Model::RankedEntities
- Inherits:
-
Object
- Object
- Attune::Model::RankedEntities
- Defined in:
- lib/attune/models/ranked_entities.rb
Overview
List of ids in ranked order. If an error occurs, returns message and status code.
Instance Attribute Summary collapse
-
#message ⇒ String
Error message if ranking failed.
-
#ranking ⇒ Array<String>
List of ids in ranked order.
-
#status ⇒ Integer
HTTP status code if ranking failed.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ RankedEntities
constructor
A new instance of RankedEntities.
- #to_body ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ RankedEntities
Returns a new instance of RankedEntities.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/attune/models/ranked_entities.rb', line 18 def initialize(attributes = {}) return if attributes.empty? # Workaround since JSON.parse has accessors as strings rather than symbols @message = attributes["message"] || attributes[:"message"] # Workaround since JSON.parse has accessors as strings rather than symbols @status = attributes["status"] || attributes[:"status"] value = attributes["ranking"] || attributes[:"ranking"] if value.is_a?(Array) @ranking = value end end |
Instance Attribute Details
#message ⇒ String
Error message if ranking failed
8 9 10 |
# File 'lib/attune/models/ranked_entities.rb', line 8 def @message end |
#ranking ⇒ Array<String>
List of ids in ranked order
8 9 10 |
# File 'lib/attune/models/ranked_entities.rb', line 8 def ranking @ranking end |
#status ⇒ Integer
HTTP status code if ranking failed
8 9 10 |
# File 'lib/attune/models/ranked_entities.rb', line 8 def status @status end |
Instance Method Details
#to_body ⇒ Object
33 34 35 36 37 38 |
# File 'lib/attune/models/ranked_entities.rb', line 33 def to_body Hash[ATTRIBUTE_MAP.map do |internal, external| next unless value = send(internal) [external, value] end.compact] end |
#to_json(options = {}) ⇒ Object
40 41 42 |
# File 'lib/attune/models/ranked_entities.rb', line 40 def to_json( = {}) to_body.to_json end |