Module: GiantBombApi::Resource
- Included in:
- Image, Response
- Defined in:
- lib/giant_bomb_api/resource.rb
Defined Under Namespace
Classes: Accessory, Character, Chat, Company, Concept, Factory, Franchise, Game, GameRating, Genre, Image, Location, Object, Person, Platform, Promo, RatingBoard, Region, Release, Review, Theme, UserReview, Video, VideoType
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.extended(base) ⇒ Object
4
5
6
7
8
9
10
11
|
# File 'lib/giant_bomb_api/resource.rb', line 4
def self.extended(base)
base.instance_variable_set("@resource_attributes", {})
base.include ResourceValueSetter
base.class_eval do
resource_attribute :id, :api_detail_url, :date_added, :date_last_updated
end
end
|
Instance Method Details
#find(id, params = {}) ⇒ Object
#resource_attribute(*attributes, resource_name: nil) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/giant_bomb_api/resource.rb', line 24
def resource_attribute(*attributes, resource_name: nil)
attributes.each do |attribute_name|
instance_variable_get("@resource_attributes")[attribute_name] = resource_name
class_eval do
attr_accessor attribute_name
end
end
end
|
#resource_name(resource_name = nil) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/giant_bomb_api/resource.rb', line 13
def resource_name(resource_name = nil)
if resource_name.present?
self.instance_variable_set("@resource_name", resource_name)
end
self.instance_variable_get("@resource_name") || self.name.split('::').last.underscore
end
|