lib/ably/models/stats.rb in ably-0.8.8 vs lib/ably/models/stats.rb in ably-0.8.9

- old
+ new

@@ -115,65 +115,65 @@ # # @param hash_object [Hash] object with the underlying stat details # def initialize(hash_object) @raw_hash_object = hash_object - set_hash_object hash_object + set_attributes_object hash_object end # Aggregates inbound and outbound messages # @return {Stats::MessageTypes} def all - @all ||= Stats::MessageTypes.new(hash[:all]) + @all ||= Stats::MessageTypes.new(attributes[:all]) end # All inbound messages i.e. received by Ably from clients # @return {Stats::MessageTraffic} def inbound - @inbound ||= Stats::MessageTraffic.new(hash[:inbound]) + @inbound ||= Stats::MessageTraffic.new(attributes[:inbound]) end # All outbound messages i.e. sent from Ably to clients # @return {Stats::MessageTraffic} def outbound - @outbound ||= Stats::MessageTraffic.new(hash[:outbound]) + @outbound ||= Stats::MessageTraffic.new(attributes[:outbound]) end # Messages persisted for later retrieval via the history API # @return {Stats::MessageTypes} def persisted - @persisted ||= Stats::MessageTypes.new(hash[:persisted]) + @persisted ||= Stats::MessageTypes.new(attributes[:persisted]) end # Breakdown of connection stats data for different (TLS vs non-TLS) connection types # @return {Stats::ConnectionTypes} def connections - @connections ||= Stats::ConnectionTypes.new(hash[:connections]) + @connections ||= Stats::ConnectionTypes.new(attributes[:connections]) end # Breakdown of channels stats # @return {Stats::ResourceCount} def channels - @channels ||= Stats::ResourceCount.new(hash[:channels]) + @channels ||= Stats::ResourceCount.new(attributes[:channels]) end # Breakdown of API requests received via the REST API # @return {Stats::RequestCount} def api_requests - @api_requests ||= Stats::RequestCount.new(hash[:api_requests]) + @api_requests ||= Stats::RequestCount.new(attributes[:api_requests]) end # Breakdown of Token requests received via the REST API # @return {Stats::RequestCount} def token_requests - @token_requests ||= Stats::RequestCount.new(hash[:token_requests]) + @token_requests ||= Stats::RequestCount.new(attributes[:token_requests]) end # @!attribute [r] interval_id # @return [String] The interval that this statistic applies to, see {GRANULARITY} and {INTERVAL_FORMAT_STRING} def interval_id - hash.fetch(:interval_id) + attributes.fetch(:interval_id) end # @!attribute [r] interval_time # @return [Time] A Time object representing the start of the interval def interval_time @@ -184,23 +184,23 @@ # @return [GRANULARITY] The granularity of the interval for the stat such as :day, :hour, :minute, see {GRANULARITY} def interval_granularity self.class.granularity_from_interval_id(interval_id) end - def hash - @hash_object + def attributes + @attributes end def as_json(*args) - hash.as_json(*args).reject { |key, val| val.nil? } + attributes.as_json(*args).reject { |key, val| val.nil? } end private def raw_hash_object @raw_hash_object end - def set_hash_object(hash) - @hash_object = IdiomaticRubyWrapper(hash.clone.freeze) + def set_attributes_object(new_attributes) + @attributes = IdiomaticRubyWrapper(new_attributes.clone.freeze) end end end