Class: Apiwork::Introspection::API::Resource
- Inherits:
-
Object
- Object
- Apiwork::Introspection::API::Resource
- Defined in:
- lib/apiwork/introspection/api/resource.rb
Overview
Wraps resource definitions.
Instance Method Summary collapse
-
#actions ⇒ Hash{Symbol => Introspection::Action}
The actions for this resource.
-
#identifier ⇒ String
The identifier for this resource.
-
#initialize(dump) ⇒ Resource
constructor
A new instance of Resource.
-
#parent_identifiers ⇒ Array<String>
The parent identifiers for this resource.
-
#path ⇒ String
The path for this resource.
-
#resources ⇒ Hash{Symbol => Resource}
The nested resources for this resource.
-
#scope ⇒ String?
The scope for this resource.
-
#to_h ⇒ Hash
Converts this resource to a hash.
Constructor Details
#initialize(dump) ⇒ Resource
Returns a new instance of Resource.
22 23 24 |
# File 'lib/apiwork/introspection/api/resource.rb', line 22 def initialize(dump) @dump = dump end |
Instance Method Details
#actions ⇒ Hash{Symbol => Introspection::Action}
The actions for this resource.
63 64 65 |
# File 'lib/apiwork/introspection/api/resource.rb', line 63 def actions @actions ||= @dump[:actions].transform_values { |dump| Action.new(dump) } end |
#identifier ⇒ String
The identifier for this resource.
38 39 40 |
# File 'lib/apiwork/introspection/api/resource.rb', line 38 def identifier @dump[:identifier] end |
#parent_identifiers ⇒ Array<String>
The parent identifiers for this resource.
54 55 56 |
# File 'lib/apiwork/introspection/api/resource.rb', line 54 def parent_identifiers @dump[:parent_identifiers] end |
#path ⇒ String
The path for this resource.
46 47 48 |
# File 'lib/apiwork/introspection/api/resource.rb', line 46 def path @dump[:path] end |
#resources ⇒ Hash{Symbol => Resource}
The nested resources for this resource.
71 72 73 |
# File 'lib/apiwork/introspection/api/resource.rb', line 71 def resources @resources ||= @dump[:resources].transform_values { |dump| Resource.new(dump) } end |
#scope ⇒ String?
The scope for this resource.
30 31 32 |
# File 'lib/apiwork/introspection/api/resource.rb', line 30 def scope @dump[:scope] end |
#to_h ⇒ Hash
Converts this resource to a hash.
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/apiwork/introspection/api/resource.rb', line 79 def to_h { actions: actions.transform_values(&:to_h), identifier: identifier, parent_identifiers: parent_identifiers, path: path, resources: resources.transform_values(&:to_h), scope: scope, } end |