Module: Instagram::Response

Defined in:
lib/instagram/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#metaObject (readonly)

Returns the value of attribute meta.



24
25
26
# File 'lib/instagram/response.rb', line 24

def meta
  @meta
end

#paginationObject (readonly)

Returns the value of attribute pagination.



23
24
25
# File 'lib/instagram/response.rb', line 23

def pagination
  @pagination
end

#ratelimitObject (readonly)

Returns the value of attribute ratelimit.



25
26
27
# File 'lib/instagram/response.rb', line 25

def ratelimit
  @ratelimit
end

Class Method Details

.create(response_hash, ratelimit_hash) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/instagram/response.rb', line 3

def self.create(response_hash, ratelimit_hash)
  response_hash = {} unless response_hash
  data = begin
           raise if response_hash.data.nil?
           response_hash.data.dup
         rescue
           response_hash
         end
  data.extend(self)
  data.instance_exec do
    %w(pagination meta).each do |k|
      response_hash.public_send(k).tap do |v|
        instance_variable_set("@#{k}", v) if v
      end
    end
    @ratelimit = ::Hashie::Mash.new(ratelimit_hash)
  end
  data
end