Skip to content

Commit

Permalink
fix resource_struct_build
Browse files Browse the repository at this point in the history
  • Loading branch information
gtrias committed Aug 21, 2024
1 parent 8b42686 commit 2268f94
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
source 'https://rubygems.org'

# gem "rails"
gem 'activesupport'
gem 'rspec'
gem 'sorbet-coerce', '>= 0.2.6'
gem 'sorbet-static-and-runtime', '>= 0.5.11511'
24 changes: 24 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.2.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
base64 (0.2.0)
bigdecimal (3.1.8)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
diff-lcs (1.5.1)
drb (2.2.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
logger (1.6.0)
minitest (5.25.1)
polyfill (1.9.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
Expand All @@ -17,6 +37,7 @@ GEM
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
safe_type (1.1.1)
securerandom (0.3.1)
sorbet (0.5.11531)
sorbet-static (= 0.5.11531)
sorbet-coerce (0.7.0)
Expand All @@ -28,12 +49,15 @@ GEM
sorbet-static-and-runtime (0.5.11531)
sorbet (= 0.5.11531)
sorbet-runtime (= 0.5.11531)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
activesupport
rspec
sorbet-coerce (>= 0.2.6)
sorbet-static-and-runtime (>= 0.5.11511)
Expand Down
8 changes: 1 addition & 7 deletions lib/public/resource_struct_builder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# typed: strict

require 'sorbet-coerce'
require 'active_support/hash_with_indifferent_access'

module ResourceRegistry
# Constructs a resource struct (like Dtos and Entities) from a hash of arguments
Expand Down Expand Up @@ -38,13 +39,6 @@ def build(value)
build_other(value)
end
rescue TypeError, ArgumentError, TypeCoerce::CoercionError => e
CustomLogger.info(
message: "Failed to parse provided arguments into #{resource_type}",
payload: {
request: value,
response: e.to_s
}
)
raise ParseInputError, e.message
end

Expand Down
5 changes: 3 additions & 2 deletions spec/resource_struct_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'spec_helper'
require_relative '../lib/public/resource_struct_builder'

module ::ResourceRegistry
module ResourceRegistry
module DtoBuilderSpec
module Dtos
class SimpleDto < T::Struct
Expand Down Expand Up @@ -133,7 +133,8 @@ class SetDto < T::Struct
end
end

context 'with a nested value-object dto' do
# ValueObjects is an internal detail of Factorial
xcontext 'with a nested value-object dto' do
let(:dto) { ResourceRegistry::DtoBuilderSpec::Dtos::NestedValueObjectDto }
let(:period) { ValueObjects::TimeRange.new(from: Time.zone.now, to: Time.zone.now.tomorrow) }
let(:args) { { type: 'one-type', period: { from: period.from, to: period.to } } }
Expand Down

0 comments on commit 2268f94

Please sign in to comment.