Class: RedSnow::Action

Inherits:
NamedBlueprintNode show all
Defined in:
lib/redsnow/blueprint.rb

Overview

Action Blueprint AST node

represetns 'action sction'

Instance Attribute Summary collapse

Attributes inherited from NamedBlueprintNode

#description, #name

Instance Method Summary collapse

Methods inherited from NamedBlueprintNode

#ensure_description_newlines

Constructor Details

#initialize(action) ⇒ Action

Returns a new instance of Action.

Parameters:

  • action (json)


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

#examplesArray<TransactionExample>

action transaction examples

Returns:



255
256
257
# File 'lib/redsnow/blueprint.rb', line 255

def examples
  @examples
end

#methodString

HTTP request method or nil

Returns:

  • (String)

    the current value of method



255
256
257
# File 'lib/redsnow/blueprint.rb', line 255

def method
  @method
end

#parametersParameters

action-specific URI parameters or nil

Returns:

  • (Parameters)

    the current value of parameters



255
256
257
# File 'lib/redsnow/blueprint.rb', line 255

def parameters
  @parameters
end

#relationString

action relation attribute

Returns:

  • (String)

    the current value of relation



255
256
257
# File 'lib/redsnow/blueprint.rb', line 255

def relation
  @relation
end

#uri_templateString

action uri template attribute

Returns:

  • (String)

    the current value of uri_template



255
256
257
# File 'lib/redsnow/blueprint.rb', line 255

def uri_template
  @uri_template
end