Class: AppnexusApi::Resource
- Inherits:
-
Object
- Object
- AppnexusApi::Resource
show all
- Defined in:
- lib/appnexusapi/resource.rb
Direct Known Subclasses
AdServerResource, BidderInstanceResource, BidderProfileResource, BidderResource, BrandResource, BrowserResource, CategoryResource, ContentCategoryResource, CreativeResource, DomainListResource, InventoryAttributeResource, InventorySourceResource, LanguageResource, MemberResource, PlatformMemberResource, SegmentResource, TechnicalAttributeService, TinyTagResource, UserResource
Instance Method Summary
collapse
Constructor Details
#initialize(json, service) ⇒ Resource
Returns a new instance of Resource.
3
4
5
6
|
# File 'lib/appnexusapi/resource.rb', line 3
def initialize(json, service)
@json = json
@service = service
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/appnexusapi/resource.rb', line 21
def method_missing(sym, *args, &block)
if @json.respond_to?(sym)
@json.send(sym, *args, &block)
elsif @json.has_key?(sym.to_s)
return @json[sym.to_s]
else
super(sym, *args, &block)
end
end
|
Instance Method Details
#delete ⇒ Object
13
14
15
|
# File 'lib/appnexusapi/resource.rb', line 13
def delete
@service.delete(id)
end
|
#raw_json ⇒ Object
17
18
19
|
# File 'lib/appnexusapi/resource.rb', line 17
def raw_json
@json
end
|
#to_s ⇒ Object
31
32
33
|
# File 'lib/appnexusapi/resource.rb', line 31
def to_s
@json.inspect
end
|
#update(attributes = {}) ⇒ Object
8
9
10
11
|
# File 'lib/appnexusapi/resource.rb', line 8
def update(attributes={})
resource = @service.update(id, attributes)
@json = resource.raw_json
end
|