# Using dry-struct with dry-system

**URL:** <https://discourse.dry-rb.org/t/using-dry-struct-with-dry-system/1046>\
**Category:** Support\
**Created:** [April 26, 2020, 6:19pm UTC](https://discourse.dry-rb.org/t/using-dry-struct-with-dry-system/1046 "2020-04-26T18:19:49Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![adamnbowen](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/adamnbowen/32/511_2.png) [@adamnbowen](https://discourse.dry-rb.org/u/adamnbowen)\
**Post date:** [April 26, 2020, 6:19pm UTC](https://discourse.dry-rb.org/t/using-dry-struct-with-dry-system/1046/1 "2020-04-26T18:19:49Z")

</div>

I’m a bit confused about how dry-struct fits into dry-system.

The auto injector assumes that any dependency I import should get `.new` called on it before providing it as a method on the current object, but this doesn’t behave well with importing a dry-struct. I understand I can manually register a struct, so I can then pass `.new` myself with the required arguments, but is this even something I should be doing with dry-system? Perhaps I shouldn’t think of my structs as the types of “dependencies” that dry-system wants me to import, but I thought I’d ask here for some clarification.

Here’s a brief (and overly-simplified) example of what I’m talking about:

```ruby
# system/container.rb
#...
require "structs/note"
Application.register "note", Structs::Note

# lib/cli/commands/create_note.rb
class CreateNote
  include Import['note']

  def call(params)
    note.new params
  end
end

```

I could avoid the above by doing something like the following, but I’m not sure if it’s overkill:

```ruby
# lib/interactors/note_creator.rb
require "structs/note"
class NoteCreator
  include Dry::Monads[:result]
  include Dry::Monads::Do.for(:call)

  def call(params)
    Success(Structs::Note.new(params))
  end
end

# lib/cli/commands/create_note.rb
class CreateNote
  include Import['interactors.note_creator']

  def call(params)
    note_creator.call params
  end
end

```

Am I misunderstanding the purpose of dry-system and over-using it a bit? Any guidance anyone could provide would be very appreciated ❤

---

_[View the full topic](https://discourse.dry-rb.org/t/using-dry-struct-with-dry-system/1046)._
