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
-
#cell ⇒ String
Cell assignment.
-
#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.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/attune/models/ranked_entities.rb', line 22 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 @cell = attributes["cell"] || attributes[:"cell"] value = attributes["ranking"] || attributes[:"ranking"] if value.is_a?(Array) @ranking = value end # Workaround since JSON.parse has accessors as strings rather than symbols @status = attributes["status"] || attributes[:"status"] end |
Instance Attribute Details
#cell ⇒ String
Cell assignment
9 10 11 |
# File 'lib/attune/models/ranked_entities.rb', line 9 def cell @cell end |
#message ⇒ String
Error message if ranking failed
9 10 11 |
# File 'lib/attune/models/ranked_entities.rb', line 9 def @message end |
#ranking ⇒ Array<String>
List of ids in ranked order
9 10 11 |
# File 'lib/attune/models/ranked_entities.rb', line 9 def ranking @ranking end |
#status ⇒ Integer
HTTP status code if ranking failed
9 10 11 |
# File 'lib/attune/models/ranked_entities.rb', line 9 def status @status end |
Instance Method Details
#to_body ⇒ Object
39 40 41 42 43 44 |
# File 'lib/attune/models/ranked_entities.rb', line 39 def to_body Hash[ATTRIBUTE_MAP.map do |internal, external| next unless value = send(internal) [external, value] end.compact] end |
#to_json(options = {}) ⇒ Object
46 47 48 |
# File 'lib/attune/models/ranked_entities.rb', line 46 def to_json( = {}) to_body.to_json end |