Class: GoogleApis::Api::Base::Resource
- Inherits:
-
Object
- Object
- GoogleApis::Api::Base::Resource
- Defined in:
- lib/google_apis/api/base/resource.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#discovered_resource ⇒ Object
Returns the value of attribute discovered_resource.
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(api, discovered_resource) ⇒ Resource
constructor
A new instance of Resource.
- #inspect ⇒ Object
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(api, discovered_resource) ⇒ Resource
Returns a new instance of Resource.
8 9 10 11 |
# File 'lib/google_apis/api/base/resource.rb', line 8 def initialize(api, discovered_resource) @api = api @discovered_resource = discovered_resource end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/google_apis/api/base/resource.rb', line 23 def method_missing(name, *args) if method = find(name) api.execute method, *args else super end end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
6 7 8 |
# File 'lib/google_apis/api/base/resource.rb', line 6 def api @api end |
#discovered_resource ⇒ Object
Returns the value of attribute discovered_resource.
6 7 8 |
# File 'lib/google_apis/api/base/resource.rb', line 6 def discovered_resource @discovered_resource end |
Instance Method Details
#[](name) ⇒ Object
13 14 15 16 17 |
# File 'lib/google_apis/api/base/resource.rb', line 13 def [](name) if method = find(name) method.discovery_document end end |
#inspect ⇒ Object
19 20 21 |
# File 'lib/google_apis/api/base/resource.rb', line 19 def inspect "#<#{api.class}::Resource:#{object_hexid} #{api.discovered_api.version}:#{discovered_resource.name}:[#{discovered_resource.discovered_methods.collect(&:name).sort.join(",")}]>" end |