Class: Curlybars::PartialPresenter
- Inherits:
-
Object
- Object
- Curlybars::PartialPresenter
- Extended by:
- MethodWhitelist
- Defined in:
- lib/curlybars/partial_presenter.rb
Instance Method Summary collapse
-
#allowed_methods ⇒ Object
Subclasses that call allow_methods get their allowed_methods via super, which includes these dynamic data keys.
- #allows_method?(method) ⇒ Boolean
-
#initialize(_context, data = {}) ⇒ PartialPresenter
constructor
A new instance of PartialPresenter.
Methods included from MethodWhitelist
Constructor Details
#initialize(_context, data = {}) ⇒ PartialPresenter
Returns a new instance of PartialPresenter.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/curlybars/partial_presenter.rb', line 5 def initialize(_context, data = {}) @_safe_keys = Set.new data.symbolize_keys.each do |key, value| next if respond_to?(key, true) define_singleton_method(key) { value } @_safe_keys.add(key) end @_safe_keys.freeze end |
Instance Method Details
#allowed_methods ⇒ Object
Subclasses that call allow_methods get their allowed_methods via super, which includes these dynamic data keys.
18 19 20 |
# File 'lib/curlybars/partial_presenter.rb', line 18 def allowed_methods @_safe_keys.to_a end |
#allows_method?(method) ⇒ Boolean
22 23 24 |
# File 'lib/curlybars/partial_presenter.rb', line 22 def allows_method?(method) @_safe_keys.include?(method.to_sym) end |