Sha256: 673df53afe274bf35a08ce769e22f863ad51331125bdb2a886a43d1c9960dfa7
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
module Attune module Model # List of ids in ranked order. If an error occurs, returns message and status code. # # @attr [String] message Error message if ranking failed # @attr [Integer] status HTTP status code if ranking failed # @attr [Array<String>] ranking List of ids in ranked order class RankedEntities attr_accessor :message attr_accessor :status attr_accessor :ranking 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 def to_body Hash[ATTRIBUTE_MAP.map do |internal, external| next unless value = send(internal) [external, value] end.compact] end def to_json(options = {}) to_body.to_json end private # :internal => :external ATTRIBUTE_MAP = { :message => :message, :status => :status, :ranking => :ranking } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
attune-1.0.12 | lib/attune/models/ranked_entities.rb |
attune-1.0.11 | lib/attune/models/ranked_entities.rb |
attune-1.0.10 | lib/attune/models/ranked_entities.rb |