Class: RedSnow::Action
- Inherits:
-
NamedBlueprintNode
- Object
- BlueprintNode
- NamedBlueprintNode
- RedSnow::Action
- Defined in:
- lib/redsnow/blueprint.rb
Overview
Action Blueprint AST node
represetns 'action sction'
Instance Attribute Summary collapse
-
#examples ⇒ Array<TransactionExample>
action transaction examples.
-
#method ⇒ String
HTTP request method or nil.
-
#parameters ⇒ Parameters
action-specific URI parameters or nil.
-
#relation ⇒ String
action relation attribute.
-
#uri_template ⇒ String
action uri template attribute.
Attributes inherited from NamedBlueprintNode
Instance Method Summary collapse
-
#initialize(action) ⇒ Action
constructor
A new instance of Action.
Methods inherited from NamedBlueprintNode
Constructor Details
#initialize(action) ⇒ Action
Returns a new instance of Action.
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/redsnow/blueprint.rb', line 263 def initialize(action) @name = action.fetch('name', '') @description = action.fetch('description', '') @method = action.fetch('method', '') @parameters = Parameters.new(action.fetch('parameters', nil)) if action.key?('attributes') @relation = action['attributes'].fetch('relation', '') @uri_template = action['attributes'].fetch('uriTemplate', '') end @examples = [] action.key?('examples') && action['examples'].each do |example| @examples << TransactionExample.new(example).tap do |inst| action_instance = self inst.define_singleton_method(:action) { action_instance } end end end |
Instance Attribute Details
#examples ⇒ Array<TransactionExample>
action transaction examples
255 256 257 |
# File 'lib/redsnow/blueprint.rb', line 255 def examples @examples end |
#method ⇒ String
HTTP request method or nil
255 256 257 |
# File 'lib/redsnow/blueprint.rb', line 255 def method @method end |
#parameters ⇒ Parameters
action-specific URI parameters or nil
255 256 257 |
# File 'lib/redsnow/blueprint.rb', line 255 def parameters @parameters end |
#relation ⇒ String
action relation attribute
255 256 257 |
# File 'lib/redsnow/blueprint.rb', line 255 def relation @relation end |
#uri_template ⇒ String
action uri template attribute
255 256 257 |
# File 'lib/redsnow/blueprint.rb', line 255 def uri_template @uri_template end |