Sha256: c7e715952263f38467358172dd338e6372424a984d99ac224fec37a4b6202bc1

Contents?: true

Size: 793 Bytes

Versions: 10

Compression:

Stored size: 793 Bytes

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)

    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 primitive(sym)
        SoberSwag::Types.const_get(sym)
      end

      def param(sym)
        SoberSwag::Types::Params.const_get(sym)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sober_swag-0.11.0 lib/sober_swag/input_object.rb
sober_swag-0.10.0 lib/sober_swag/input_object.rb
sober_swag-0.9.0 lib/sober_swag/input_object.rb
sober_swag-0.8.0 lib/sober_swag/input_object.rb
sober_swag-0.7.0 lib/sober_swag/input_object.rb
sober_swag-0.6.0 lib/sober_swag/input_object.rb
sober_swag-0.5.0 lib/sober_swag/input_object.rb
sober_swag-0.4.0 lib/sober_swag/input_object.rb
sober_swag-0.3.0 lib/sober_swag/input_object.rb
sober_swag-0.2.0 lib/sober_swag/input_object.rb