class Jet::Contract::Builder
Attributes
checks[R]
types[R]
Public Class Methods
new(attribute_builders = {})
click to toggle source
# File lib/jet/contract/builder.rb, line 8 def initialize(attribute_builders = {}) @attribute_builders = attribute_builders.dup end
Public Instance Methods
[](key)
click to toggle source
# File lib/jet/contract/builder.rb, line 12 def [](key) @attribute_builders[key] end
attribute_builders()
click to toggle source
# File lib/jet/contract/builder.rb, line 20 def attribute_builders @attribute_builders.dup end
Also aliased as: to_h
call(*args)
click to toggle source
# File lib/jet/contract/builder.rb, line 16 def call(*args) Contract.new(@attribute_builders.transform_values { |ab| ab.(*args) }) end
optional(key)
click to toggle source
# File lib/jet/contract/builder.rb, line 25 def optional(key) attribute_builder(key, false) end
required(key)
click to toggle source
# File lib/jet/contract/builder.rb, line 29 def required(key) attribute_builder(key, true) end
Private Instance Methods
attribute_builder(key, required)
click to toggle source
# File lib/jet/contract/builder.rb, line 35 def attribute_builder(key, required) @attribute_builders[key.to_sym] = Attribute::Builder.new(required: required) end