Class: Dryer::Factories::GeneratedPayload
- Inherits:
-
Object
- Object
- Dryer::Factories::GeneratedPayload
- Defined in:
- lib/dryer/factories/generated_payload.rb
Instance Attribute Summary collapse
-
#contract ⇒ Object
readonly
Returns the value of attribute contract.
Instance Method Summary collapse
- #as_json ⇒ Object
- #create_instance_variables ⇒ Object
-
#initialize(contract:, fields:) ⇒ GeneratedPayload
constructor
A new instance of GeneratedPayload.
- #to_h ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(contract:, fields:) ⇒ GeneratedPayload
Returns a new instance of GeneratedPayload.
4 5 6 7 8 |
# File 'lib/dryer/factories/generated_payload.rb', line 4 def initialize(contract:, fields:) @contract = contract @fields = fields create_instance_variables end |
Instance Attribute Details
#contract ⇒ Object (readonly)
Returns the value of attribute contract.
28 29 30 |
# File 'lib/dryer/factories/generated_payload.rb', line 28 def contract @contract end |
Instance Method Details
#as_json ⇒ Object
20 21 22 |
# File 'lib/dryer/factories/generated_payload.rb', line 20 def as_json to_h end |
#create_instance_variables ⇒ Object
10 11 12 13 14 |
# File 'lib/dryer/factories/generated_payload.rb', line 10 def create_instance_variables fields.inject(self) do |obj, (name, value)| self.define_singleton_method(name.to_sym) { value } end end |
#to_h ⇒ Object
16 17 18 |
# File 'lib/dryer/factories/generated_payload.rb', line 16 def to_h fields end |
#to_json ⇒ Object
24 25 26 |
# File 'lib/dryer/factories/generated_payload.rb', line 24 def to_json to_h.to_json end |