class TicketflyApi::HashBasedStore

Public Class Methods

new(connection, attribute_map, nested_class_map, options) click to toggle source
# File lib/ticketfly-api/hash_based_store.rb, line 3
def initialize(connection, attribute_map, nested_class_map, options)
  @connection = connection
  @valid_attributes = attribute_map
  @nested_class_map = nested_class_map

  @values = {}
  @valid_attributes.each do |json_key, ruby_key|
    value = options[json_key]
    @values[ruby_key] = value.is_a?(Hash) ? @nested_class_map[ruby_key].new(@connection, value) : value
  end
end

Public Instance Methods

[](key) click to toggle source
# File lib/ticketfly-api/hash_based_store.rb, line 15
def [](key)
  @values[key]
end
id() click to toggle source

This needs to be explicit because otherwise you get the Object#id method (which is depreciated) rather than method missing getting called

# File lib/ticketfly-api/hash_based_store.rb, line 21
def id
  @values[:id]
end
inspect()
Also aliased as: original_inspect
Alias for: to_s
merge(other) click to toggle source
# File lib/ticketfly-api/hash_based_store.rb, line 38
def merge(other)
  @valid_attributes.each do |json_key, ruby_key|
    @values[ruby_key] = other[ruby_key] if other[ruby_key]
  end
end
method_missing(symbol, *args) click to toggle source
# File lib/ticketfly-api/hash_based_store.rb, line 44
def method_missing(symbol, *args)
  if @valid_attributes.values.include?(symbol)
    @values[symbol]
  else
    raise InternalError
  end
end
original_inspect()

cleanup how StravaApi objects are displayed in irb

Alias for: inspect
to_s() click to toggle source
# File lib/ticketfly-api/hash_based_store.rb, line 25
def to_s
  result = []
  @values.each do |key, value|
    result << ":#{key} => #{value}" if value
  end
  
  "#<#{self.class} [#{result.join(', ')}]>"
end
Also aliased as: inspect