class Realm::Contract
Public Class Methods
json(*external_schemas, **attributes, &block)
click to toggle source
Calls superclass method
# File lib/realm/contract.rb, line 22 def json(*external_schemas, **attributes, &block) super(*sanitize_schemas(external_schemas, attributes, :json), &block) end
params(*external_schemas, **attributes, &block)
click to toggle source
Calls superclass method
# File lib/realm/contract.rb, line 18 def params(*external_schemas, **attributes, &block) super(*sanitize_schemas(external_schemas, attributes, :params), &block) end
schema(*external_schemas, **attributes, &block)
click to toggle source
Calls superclass method
# File lib/realm/contract.rb, line 14 def schema(*external_schemas, **attributes, &block) super(*sanitize_schemas(external_schemas, attributes, :schema), &block) end
Private Class Methods
convert_to_schema(thing, type)
click to toggle source
# File lib/realm/contract.rb, line 33 def convert_to_schema(thing, type) return thing if thing.is_a? Dry::Schema::Processor # already a schema raise NotConvertibleToSchema, thing unless thing.respond_to?(:to_dry_schema) thing.to_dry_schema(type: type) end
sanitize_schemas(things, attributes, type)
click to toggle source
# File lib/realm/contract.rb, line 28 def sanitize_schemas(things, attributes, type) things << Realm.Struct(attributes) if attributes.present? things.map { |thing| convert_to_schema(thing, type) } end