Class: HaveAPI::Metadata::ActionMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/haveapi/metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#action=(value) ⇒ Object (writeonly)

Sets the attribute action

Parameters:

  • value

    the value to set the attribute action to.



14
15
16
# File 'lib/haveapi/metadata.rb', line 14

def action=(value)
  @action = value
end

Instance Method Details

#cloneObject



16
17
18
19
20
21
22
# File 'lib/haveapi/metadata.rb', line 16

def clone
  m = self.class.new
  m.action = @action
  m.instance_variable_set(:@input, @input && @input.clone)
  m.instance_variable_set(:@output, @output && @output.clone)
  m
end

#describe(context) ⇒ Object



48
49
50
51
52
53
# File 'lib/haveapi/metadata.rb', line 48

def describe(context)
  {
    input: @input && @input.describe(context),
    output: @output && @output.describe(context)
  }
end

#input(layout = :hash, &block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/haveapi/metadata.rb', line 24

def input(layout = :hash, &block)
  if block
    @input ||= Params.new(:input, @action)
    @input.action = @action
    @input.layout = layout
    @input.namespace = false
    @input.add_block(block)
  else
    @input
  end
end

#output(layout = :hash, &block) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/haveapi/metadata.rb', line 36

def output(layout = :hash, &block)
  if block
    @output ||= Params.new(:output, @action)
    @output.action = @action
    @output.layout = layout
    @output.namespace = false
    @output.add_block(block)
  else
    @output
  end
end