class Layer::Resource
Attributes
client[W]
attributes[RW]
client[RW]
Public Class Methods
class_name()
click to toggle source
# File lib/layer/resource.rb, line 7 def class_name name.split('::')[-1] end
client()
click to toggle source
# File lib/layer/resource.rb, line 19 def client @client ||= Client::Platform.new end
from_response(attributes, client)
click to toggle source
# File lib/layer/resource.rb, line 15 def from_response(attributes, client) new(attributes, client) end
new(attributes = {}, client = self.class.client)
click to toggle source
# File lib/layer/resource.rb, line 26 def initialize(attributes = {}, client = self.class.client) self.attributes = attributes self.client = client end
url()
click to toggle source
# File lib/layer/resource.rb, line 11 def url "/#{class_name.downcase.to_s}s" end
Public Instance Methods
id()
click to toggle source
# File lib/layer/resource.rb, line 35 def id attributes['id'] end
respond_to_missing?(method, include_private = false)
click to toggle source
Calls superclass method
# File lib/layer/resource.rb, line 39 def respond_to_missing?(method, include_private = false) attribute = method.to_s.sub(/=$/, '') attributes.has_key?(attribute) || super end
url()
click to toggle source
# File lib/layer/resource.rb, line 31 def url attributes['url'] || (id && "#{self.class.url}/#{Layer::Client.normalize_id(id)}") end
Private Instance Methods
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/layer/resource.rb, line 47 def method_missing(method, *args, &block) if method.to_s =~ /=$/ attribute = method.to_s.sub(/=$/, '') attributes[attribute] = args.first elsif attributes.has_key?(method.to_s) attributes[method.to_s] else super end end