Class: GiphyAPI::Base

Inherits:
Object
  • Object
show all
Includes:
RawDataAttributes
Defined in:
lib/giphy_api/resources/base.rb

Direct Known Subclasses

Gif, Sticker

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RawDataAttributes

#assign_raw_data, included

Constructor Details

#initialize(attributes = {}) ⇒ Base

Returns a new instance of Base.



49
50
51
# File 'lib/giphy_api/resources/base.rb', line 49

def initialize attributes = {}
  assign_raw_data(attributes)
end

Class Method Details

.find_with_scope(path, scope, **options) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/giphy_api/resources/base.rb', line 5

def find_with_scope path, scope, **options
  response = format.load get(path, options).body
  case scope
  when :all
    instantiate_collection(response['data'] || [], response['pagination'] || {})
  when :one
    instantiate_record(response['data'] || {})
  end
end