Class: Praxis::Types::MultipartArray::PartDefinition
- Inherits:
-
Object
- Object
- Praxis::Types::MultipartArray::PartDefinition
- Defined in:
- lib/praxis/types/multipart_array/part_definition.rb
Instance Attribute Summary collapse
-
#filename_attribute ⇒ Object
Returns the value of attribute filename_attribute.
-
#headers_attribute ⇒ Object
Returns the value of attribute headers_attribute.
-
#payload_attribute ⇒ Object
Returns the value of attribute payload_attribute.
Instance Method Summary collapse
- #create_attribute(type = Attributor::Struct, **opts, &block) ⇒ Object
- #filename(type = String, **opts) ⇒ Object
- #header(name, val = nil, **options) ⇒ Object
-
#initialize(&block) ⇒ PartDefinition
constructor
A new instance of PartDefinition.
- #payload(type = Attributor::Struct, **opts, &block) ⇒ Object
- #update_attribute(attribute, options, block) ⇒ Object
Constructor Details
#initialize(&block) ⇒ PartDefinition
Returns a new instance of PartDefinition.
9 10 11 |
# File 'lib/praxis/types/multipart_array/part_definition.rb', line 9 def initialize(&block) instance_eval(&block) end |
Instance Attribute Details
#filename_attribute ⇒ Object
Returns the value of attribute filename_attribute.
7 8 9 |
# File 'lib/praxis/types/multipart_array/part_definition.rb', line 7 def filename_attribute @filename_attribute end |
#headers_attribute ⇒ Object
Returns the value of attribute headers_attribute.
7 8 9 |
# File 'lib/praxis/types/multipart_array/part_definition.rb', line 7 def headers_attribute @headers_attribute end |
#payload_attribute ⇒ Object
Returns the value of attribute payload_attribute.
7 8 9 |
# File 'lib/praxis/types/multipart_array/part_definition.rb', line 7 def payload_attribute @payload_attribute end |
Instance Method Details
#create_attribute(type = Attributor::Struct, **opts, &block) ⇒ Object
18 19 20 21 |
# File 'lib/praxis/types/multipart_array/part_definition.rb', line 18 def create_attribute(type = Attributor::Struct, **opts, &block) # TODO: how do we want to handle any referenced types? Attributor::Attribute.new(type, opts, &block) end |
#filename(type = String, **opts) ⇒ Object
43 44 45 |
# File 'lib/praxis/types/multipart_array/part_definition.rb', line 43 def filename(type = String, **opts) @filename_attribute = create_attribute(type, **opts) end |
#header(name, val = nil, **options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/praxis/types/multipart_array/part_definition.rb', line 28 def header(name, val = nil, **) block = proc { header(name, val, **) } if @headers_attribute update_attribute(@headers_attribute, , block) else type = Attributor::Hash.of(key: String) @headers_attribute = create_attribute(type, dsl_compiler: Praxis::ActionDefinition::HeadersDSLCompiler, case_insensitive_load: false, # :( allow_extra: true, &block) end end |
#payload(type = Attributor::Struct, **opts, &block) ⇒ Object
23 24 25 26 |
# File 'lib/praxis/types/multipart_array/part_definition.rb', line 23 def payload(type = Attributor::Struct, **opts, &block) # return @payload if !block_given? && type == Attributor::Struct @payload_attribute = create_attribute(type, **opts, &block) end |
#update_attribute(attribute, options, block) ⇒ Object
13 14 15 16 |
# File 'lib/praxis/types/multipart_array/part_definition.rb', line 13 def update_attribute(attribute, , block) attribute..merge!() attribute.type.attributes(**, &block) end |