Class: HaveAPI::Metadata::ActionMetadata
- Inherits:
-
Object
- Object
- HaveAPI::Metadata::ActionMetadata
- Defined in:
- lib/haveapi/metadata.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
writeonly
Sets the attribute action.
Instance Method Summary collapse
- #clone ⇒ Object
- #describe(context, type:) ⇒ Object
- #input(layout = :hash, &block) ⇒ Object
- #output(layout = :hash, &block) ⇒ Object
- #parameter_metadata_i18n_items(context, type:) ⇒ Object
Instance Attribute Details
#action=(value) ⇒ Object (writeonly)
Sets the attribute action
14 15 16 |
# File 'lib/haveapi/metadata.rb', line 14 def action=(value) @action = value end |
Instance Method Details
#clone ⇒ Object
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, type:) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/haveapi/metadata.rb', line 48 def describe(context, type:) { input: @input && @input.describe( context, i18n_path: Params.(context, type, :input) ), output: @output && @output.describe( context, metadata: true, i18n_path: Params.(context, type, :output) ) } 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 |
#parameter_metadata_i18n_items(context, type:) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/haveapi/metadata.rb', line 62 def (context, type:) [ *@input&.( context, i18n_path: Params.(context, type, :input), meta_type: type ), *@output&.( context, i18n_path: Params.(context, type, :output), meta_type: type ) ].compact end |