Skip to content
This repository was archived by the owner on Oct 21, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apiblueprint.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |s|

s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]

s.add_dependency "dry-types"
s.add_dependency "dry-types", ">= 1.4"
s.add_dependency "dry-struct"
s.add_dependency "dry-initializer"
s.add_dependency "dry-configurable"
Expand Down
12 changes: 6 additions & 6 deletions lib/api-blueprint/blueprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ module ApiBlueprint
class Blueprint < ApiBlueprint::Struct
attribute :http_method, Types::Symbol.default(:get).enum(*Faraday::Connection::METHODS)
attribute :url, Types::String
attribute :headers, Types::Hash.default(Hash.new)
attribute :params, Types::Hash.default(Hash.new)
attribute :body, Types::Hash.default(Hash.new)
attribute :headers, Types::Hash.default { Hash.new }
attribute :params, Types::Hash.default { Hash.new }
attribute :body, Types::Hash.default { Hash.new }
attribute :creates, Types::Any
attribute :parser, Types.Instance(ApiBlueprint::Parser).optional.default(ApiBlueprint::Parser.new)
attribute :replacements, Types::Hash.default(Hash.new)
attribute :parser, Types.Instance(ApiBlueprint::Parser).optional.default { ApiBlueprint::Parser.new }
attribute :replacements, Types::Hash.default { Hash.new }
attribute :after_build, Types::Instance(Proc).optional
attribute :builder, Types.Instance(ApiBlueprint::Builder).default(ApiBlueprint::Builder.new)
attribute :builder, Types.Instance(ApiBlueprint::Builder).default { ApiBlueprint::Builder.new }
attribute :log_responses, Types::Strict::Bool.default(false)
attribute :timeout, Types::Strict::Integer.default(5)

Expand Down
6 changes: 3 additions & 3 deletions lib/api-blueprint/builder.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module ApiBlueprint
class Builder < ApiBlueprint::Struct

attribute :body, Types::Hash.default(Hash.new)
attribute :headers, Types::Hash.default(Hash.new)
attribute :body, Types::Hash.default { Hash.new }
attribute :headers, Types::Hash.default { Hash.new }
attribute :status, Types::Integer.optional
attribute :replacements, Types::Hash.default(Hash.new)
attribute :replacements, Types::Hash.default { Hash.new }
attribute :creates, Types::Any.optional

attr_writer :body
Expand Down
2 changes: 1 addition & 1 deletion lib/api-blueprint/struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Struct < Dry::Struct
transform_keys &:to_sym

transform_types do |type|
type.default? ? type : type.meta(omittable: true)
type.default? ? type : type.omittable
end

def self.new(attributes = default_attributes)
Expand Down
2 changes: 1 addition & 1 deletion lib/api-blueprint/types.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Types
include Dry::Types.module
include Dry::Types()
end