Class: GitlabRuby::APIObject
- Inherits:
-
Hash
- Object
- Hash
- GitlabRuby::APIObject
show all
- Defined in:
- lib/gitlab_ruby/api_object.rb
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ APIObject
3
4
5
6
|
# File 'lib/gitlab_ruby/api_object.rb', line 3
def initialize(data)
super()
data.each { |key, val| self[key] = val } if data.is_a?(Hash)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &blk) ⇒ Object
17
18
19
|
# File 'lib/gitlab_ruby/api_object.rb', line 17
def method_missing(method, *args, &blk)
format(self[method.to_s]) || super
end
|
Instance Method Details
8
9
10
11
12
13
14
15
|
# File 'lib/gitlab_ruby/api_object.rb', line 8
def format(val)
return if val.nil?
if val.class == Hash
APIObject.new(val)
else
val
end
end
|
#respond_to_missing?(method, include_all = false) ⇒ Boolean
21
22
23
|
# File 'lib/gitlab_ruby/api_object.rb', line 21
def respond_to_missing?(method, include_all = false)
key?(method.to_s) || super
end
|