Class: RestfulResource::OpenObject
- Inherits:
-
Object
- Object
- RestfulResource::OpenObject
show all
- Defined in:
- lib/restful_resource/open_object.rb
Direct Known Subclasses
Base
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}, _hack_for_activeresource = false) ⇒ OpenObject
Returns a new instance of OpenObject.
3
4
5
|
# File 'lib/restful_resource/open_object.rb', line 3
def initialize(attributes = {}, _hack_for_activeresource = false)
@inner_object = StrictOpenStruct.new(attributes)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/restful_resource/open_object.rb', line 7
def method_missing(method, *args, &block)
if @inner_object.respond_to?(method)
@inner_object.send(method, *args, &block)
else
super(method)
end
end
|
Instance Method Details
#==(other) ⇒ Object
23
24
25
|
# File 'lib/restful_resource/open_object.rb', line 23
def ==(other)
@inner_object == other.instance_variable_get(:@inner_object)
end
|
#as_json(options = nil) ⇒ Object
19
20
21
|
# File 'lib/restful_resource/open_object.rb', line 19
def as_json(options = nil)
@inner_object.send(:table).as_json(options)
end
|
#eql?(other) ⇒ Boolean
27
28
29
|
# File 'lib/restful_resource/open_object.rb', line 27
def eql?(other)
@inner_object.eql?(other.instance_variable_get(:@inner_object))
end
|
#equal?(other) ⇒ Boolean
31
32
33
|
# File 'lib/restful_resource/open_object.rb', line 31
def equal?(other)
@inner_object.equal?(other.instance_variable_get(:@inner_object))
end
|
#hash ⇒ Object
35
36
37
|
# File 'lib/restful_resource/open_object.rb', line 35
def hash
@inner_object.hash
end
|
#respond_to?(method, include_private = false) ⇒ Boolean
15
16
17
|
# File 'lib/restful_resource/open_object.rb', line 15
def respond_to?(method, include_private = false)
super || @inner_object.respond_to?(method, include_private)
end
|