Class: RedSnow::Resource
- Inherits:
-
NamedBlueprintNode
- Object
- BlueprintNode
- NamedBlueprintNode
- RedSnow::Resource
- Defined in:
- lib/redsnow/blueprint.rb
Overview
Resource Blueprint AST node
represents 'resource section'
Instance Attribute Summary collapse
-
#actions ⇒ Array<Action>
array of resource actions or nil.
-
#model ⇒ Model
model payload for the resource or nil.
-
#parameters ⇒ Parameters
action-specific URI parameters or nil.
-
#uri_template ⇒ String
RFC 6570 URI template.
Attributes inherited from NamedBlueprintNode
Instance Method Summary collapse
-
#initialize(resource) ⇒ Resource
constructor
A new instance of Resource.
Methods inherited from NamedBlueprintNode
Constructor Details
#initialize(resource) ⇒ Resource
Returns a new instance of Resource.
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/redsnow/blueprint.rb', line 300 def initialize(resource) @name = resource.fetch('name', '') @description = resource.fetch('description', '') @uri_template = resource.fetch('uriTemplate', '') @model = Payload.new(resource.fetch('model', nil)) @parameters = Parameters.new(resource.fetch('parameters', nil)) @actions = [] resource.key?('actions') && resource['actions'].each do |action| @actions << Action.new(action).tap do |inst| resource_instance = self inst.define_singleton_method(:resource) { resource_instance } end end end |
Instance Attribute Details
#actions ⇒ Array<Action>
array of resource actions or nil
293 294 295 |
# File 'lib/redsnow/blueprint.rb', line 293 def actions @actions end |
#model ⇒ Model
model payload for the resource or nil
293 294 295 |
# File 'lib/redsnow/blueprint.rb', line 293 def model @model end |
#parameters ⇒ Parameters
action-specific URI parameters or nil
293 294 295 |
# File 'lib/redsnow/blueprint.rb', line 293 def parameters @parameters end |
#uri_template ⇒ String
RFC 6570 URI template
293 294 295 |
# File 'lib/redsnow/blueprint.rb', line 293 def uri_template @uri_template end |