Module: Excom::Plugins::DryTypes
- Defined in:
- lib/excom/plugins/dry_types.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(attrs) ⇒ Object
- #initialize_clone ⇒ Object
- #with_args ⇒ Object
- #with_attributes(attrs) ⇒ Object
- #with_opts ⇒ Object
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/excom/plugins/dry_types.rb', line 5 def attributes @attributes end |
Class Method Details
.used(service_class) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/excom/plugins/dry_types.rb', line 8 def self.used(service_class, *) require 'dry-types' require 'dry-struct' service_class.const_set(:Attributes, Class.new(Dry::Struct)) end |
Instance Method Details
#initialize(attrs) ⇒ Object
15 16 17 18 19 |
# File 'lib/excom/plugins/dry_types.rb', line 15 def initialize(attrs) @attributes = self.class::Attributes.new(attrs) super end |
#initialize_clone ⇒ Object
21 22 23 24 |
# File 'lib/excom/plugins/dry_types.rb', line 21 def initialize_clone(*) @attributes = @attributes.dup super end |
#with_args ⇒ Object
43 44 45 |
# File 'lib/excom/plugins/dry_types.rb', line 43 def with_args(*) raise("`with_args' method is not available with :dry_types plugin. use `with_attributes' method instead") end |
#with_attributes(attrs) ⇒ Object
26 27 28 29 30 |
# File 'lib/excom/plugins/dry_types.rb', line 26 def with_attributes(attrs) clone.tap do |copy| copy.attributes = self.class::Attributes.new(attributes.to_hash.merge(attrs)) end end |
#with_opts ⇒ Object
47 48 49 |
# File 'lib/excom/plugins/dry_types.rb', line 47 def with_opts(*) raise("`with_opts' method is not available with :dry_types plugin. use `with_attributes' method instead") end |