Class: ReactEmailRails::PropsResolver
- Inherits:
-
Object
- Object
- ReactEmailRails::PropsResolver
- Defined in:
- lib/react_email_rails/props_resolver.rb
Constant Summary collapse
- INTERNAL_ASSIGN_PREFIX =
"_"- RESERVED_ASSIGNS =
Some Action Mailer framework assigns do not use the internal ‘_` prefix.
["params", "rendered_format"].freeze
Instance Method Summary collapse
-
#initialize(mailer) ⇒ PropsResolver
constructor
A new instance of PropsResolver.
- #resolve(react, props) ⇒ Object
Constructor Details
#initialize(mailer) ⇒ PropsResolver
Returns a new instance of PropsResolver.
6 7 8 |
# File 'lib/react_email_rails/props_resolver.rb', line 6 def initialize(mailer) @mailer = mailer end |
Instance Method Details
#resolve(react, props) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/react_email_rails/props_resolver.rb', line 10 def resolve(react, props) case react when String [react, props || {}] when Hash raise(ArgumentError, "Parameter `props` is not allowed when passing a Hash to `react`") if props [inferred_component, react] when true [inferred_component, assign_props] else raise(ArgumentError, "`react` must be a String, Hash, or true") end end |