class RocketfuelApi::Resource

Public Class Methods

new(json, service) click to toggle source
# File lib/rocketfuel_api/resource.rb, line 4
def initialize(json, service)
  @json = json
  @service = service
end

Public Instance Methods

delete(route_params = {}) click to toggle source
# File lib/rocketfuel_api/resource.rb, line 16
def delete(route_params = {})
  @service.delete(id, route_params)
end
method_missing(sym, *args, &block) click to toggle source
Calls superclass method
# File lib/rocketfuel_api/resource.rb, line 24
def method_missing(sym, *args, &block)
  if @json.respond_to?(sym)
    @json.public_send(sym, *args, &block)
  elsif @json.key?(sym.to_s)
    @json[sym.to_s]
  else
    super
  end
end
raw_json() click to toggle source
# File lib/rocketfuel_api/resource.rb, line 20
def raw_json
  @json
end
respond_to_missing?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/rocketfuel_api/resource.rb, line 34
def respond_to_missing?(method_name, include_private = false)
  @json.respond_to?(sym) || @json.key?(sym.to_s) || super
end
to_s() click to toggle source
# File lib/rocketfuel_api/resource.rb, line 38
def to_s
  @json.inspect
end
update(route_params = {}, body_params = {}) click to toggle source
# File lib/rocketfuel_api/resource.rb, line 9
def update(route_params = {}, body_params = {})
  resource = @service.update(id, route_params, body_params)
  @json = resource.raw_json

  self
end