class M2X::Client::Resource
Wrapper for M2X::Client
resources
Attributes
attributes[R]
Public Class Methods
new(client, attributes)
click to toggle source
# File lib/m2x/resource.rb, line 11 def initialize(client, attributes) @client = client @attributes = attributes end
Public Instance Methods
delete!()
click to toggle source
Delete the resource
# File lib/m2x/resource.rb, line 35 def delete! @client.delete(path) end
inspect()
click to toggle source
# File lib/m2x/resource.rb, line 39 def inspect "<#{self.class.name}: #{attributes.inspect}>" end
path()
click to toggle source
# File lib/m2x/resource.rb, line 43 def path raise NotImplementedError end
refresh()
click to toggle source
Refresh the resource details and return self
# File lib/m2x/resource.rb, line 24 def refresh view self end
update!(params)
click to toggle source
Update an existing resource details
# File lib/m2x/resource.rb, line 30 def update!(params) @client.put(path, nil, params, "Content-Type" => "application/json") end
view()
click to toggle source
Return the resource details
# File lib/m2x/resource.rb, line 17 def view res = @client.get(path) @attributes = res.json if res.success? end