Class: ReactEmailRails::SharedProps
- Inherits:
-
Object
- Object
- ReactEmailRails::SharedProps
- Defined in:
- lib/react_email_rails/shared_props.rb
Constant Summary collapse
- IVAR =
:@_react_email_shared
Instance Method Summary collapse
-
#initialize(mailer) ⇒ SharedProps
constructor
A new instance of SharedProps.
- #merge_into(props, deep_merge:) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(mailer) ⇒ SharedProps
Returns a new instance of SharedProps.
4 5 6 |
# File 'lib/react_email_rails/shared_props.rb', line 4 def initialize(mailer) @mailer = mailer end |
Instance Method Details
#merge_into(props, deep_merge:) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/react_email_rails/shared_props.rb', line 8 def merge_into(props, deep_merge:) shared = to_h return props if shared.empty? base = shared.as_json incoming = props.as_json deep_merge ? base.deep_merge(incoming) : base.merge(incoming) end |
#to_h ⇒ Object
17 18 19 20 21 |
# File 'lib/react_email_rails/shared_props.rb', line 17 def to_h entries.each_with_object({}) do |entry, props| props.merge!(resolve(entry)) end end |