Method: Vk::Base#initialize

Defined in:
lib/vk/base.rb

#initialize(id, options = {}) ⇒ Base

Returns a new instance of Base.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vk/base.rb', line 59

def initialize(id, options = {})
  @attributes = ActiveSupport::HashWithIndifferentAccess.new

  if id.is_a?(Hash)
    options[:data] = id
    id = options[:data][key_field.to_s]
  end

  self.id = id
  self.class.identity_map[id] = self

  if options.key? :data
    @attributes.merge!(options[:data].with_indifferent_access)
  else
    load_data(options)
  end
end