Sha256: 5ce02ae478d72a8b9e4569e7c9c40fbe34e4973c7f14cecc3b42098cdee8c60f
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
module SoberSwag ## # A variant of Dry::Struct that allows you to set a "model name" that is publically visible. # If you do not set one, it will be the Ruby class name, with any '::' replaced with a '.'. # # This otherwise behaves exactly like a Dry::Struct. # Please see the documentation for that class to see how it works. class InputObject < Dry::Struct transform_keys(&:to_sym) include SoberSwag::Type::Named class << self ## # The name to use for this type in external documentation. def identifier(arg = nil) @identifier = arg if arg @identifier || name.to_s.gsub('::', '.') end def meta(*args) original = self super(*args).tap do |result| return result unless result.is_a?(Class) result.define_singleton_method(:alias?) { true } result.define_singleton_method(:alias_of) { original } end end def primitive(sym) SoberSwag::Types.const_get(sym) end def param(sym) SoberSwag::Types::Params.const_get(sym) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sober_swag-0.15.0 | lib/sober_swag/input_object.rb |