Sha256: a935149e34c58fe979156c17b761dddb214a463400a2c3a3009c524b99bba69a
Contents?: true
Size: 1.65 KB
Versions: 11
Compression:
Stored size: 1.65 KB
Contents
module Praxis module Types class MultipartArray < Attributor::Collection class PartDefinition attr_accessor :payload_attribute attr_accessor :headers_attribute attr_accessor :filename_attribute def initialize(&block) self.instance_eval(&block) end def update_attribute(attribute, options, block) attribute.options.merge!(options) attribute.type.attributes(options, &block) end def create_attribute(type=Attributor::Struct, **opts, &block) # TODO: how do we want to handle any referenced types? return Attributor::Attribute.new(type, opts, &block) end def payload(type=Attributor::Struct, **opts, &block) #return @payload if !block_given? && type == Attributor::Struct @payload_attribute = create_attribute(type, **opts, &block) end def header(name, val=nil, **options) block = proc { header(name, val, **options) } if @headers_attribute update_attribute(@headers_attribute, options, 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 def filename(type=String, **opts) @filename_attribute = create_attribute(type, **opts) end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems