Class: Loquor::Resource
- Inherits:
-
Object
show all
- Defined in:
- lib/loquor/resource.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ Resource
Returns a new instance of Resource.
4
5
6
|
# File 'lib/loquor/resource.rb', line 4
def initialize(data)
@data = ObjectHash.new(data, strict: true)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
8
9
10
11
12
|
# File 'lib/loquor/resource.rb', line 8
def method_missing(name, *args)
@data[name]
rescue
raise NameError.new("undefined local variable or method '#{name}' for #{self.class.name}")
end
|
Class Method Details
.cache ⇒ Object
31
32
33
|
# File 'lib/loquor/resource.rb', line 31
def self.cache
@value
end
|
.cache=(value) ⇒ Object
27
28
29
|
# File 'lib/loquor/resource.rb', line 27
def self.cache=(value)
@value = value
end
|
.create(payload) ⇒ Object
45
46
47
|
# File 'lib/loquor/resource.rb', line 45
def self.create(payload)
ApiCall::Create.new(self, payload: payload).execute
end
|
.find(id) ⇒ Object
35
36
37
|
# File 'lib/loquor/resource.rb', line 35
def self.find(id)
ApiCall::Show.new(self, id).execute
end
|
.path ⇒ Object
23
24
25
|
# File 'lib/loquor/resource.rb', line 23
def self.path
@path
end
|
.path=(path) ⇒ Object
19
20
21
|
# File 'lib/loquor/resource.rb', line 19
def self.path=(path)
@path = path
end
|
.update(id, payload) ⇒ Object
49
50
51
|
# File 'lib/loquor/resource.rb', line 49
def self.update(id, payload)
ApiCall::Update.new(self, id, payload: payload).execute
end
|
Instance Method Details
#respond_to?(name) ⇒ Boolean
14
15
16
17
|
# File 'lib/loquor/resource.rb', line 14
def respond_to?(name)
return true if super
@data.respond_to?(name)
end
|