Class: Hanami::Mailer::DSL::Exposure Private
- Inherits:
-
Object
- Object
- Hanami::Mailer::DSL::Exposure
- Defined in:
- lib/hanami/mailer/dsl/exposure.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
An exposure defined on a mailer.
Instance Attribute Summary collapse
- #callable ⇒ Object readonly private
- #name ⇒ Object readonly private
- #object ⇒ Object readonly private
- #options ⇒ Object readonly private
Instance Method Summary collapse
- #bind(obj) ⇒ Object private
- #call(input, locals = {}) ⇒ Object private
- #default_value ⇒ Object private
- #dependencies? ⇒ Boolean private
- #dependency_names ⇒ Object private
-
#initialize(name, proc = nil, object = nil, **options) ⇒ Exposure
constructor
private
A new instance of Exposure.
- #private? ⇒ Boolean private
- #proc ⇒ Object private
Constructor Details
#initialize(name, proc = nil, object = nil, **options) ⇒ Exposure
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Exposure.
19 20 21 22 23 24 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 19 def initialize(name, proc = nil, object = nil, **) @name = name @object = object @options = @callable = PluckyProc.from_name(proc, name, object) end |
Instance Attribute Details
#callable ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 17 def callable @callable end |
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 14 def name @name end |
#object ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 15 def object @object end |
#options ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 16 def @options end |
Instance Method Details
#bind(obj) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 26 def bind(obj) self.class.new(name, callable&.proc, obj, **) end |
#call(input, locals = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 55 56 57 58 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 52 def call(input, locals = {}) if callable call_proc(input, locals) else input.fetch(name) { default_value } end end |
#default_value ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 48 def default_value [:default] end |
#dependencies? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 40 def dependencies? !dependency_names.empty? end |
#dependency_names ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 38 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 34 def dependency_names return [] unless callable callable.dependency_names end |
#private? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 44 def private? .fetch(:private, false) end |
#proc ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/hanami/mailer/dsl/exposure.rb', line 30 def proc callable&.proc end |