Class: DynamicText::LocalsSetter
- Inherits:
-
Object
- Object
- DynamicText::LocalsSetter
- Defined in:
- lib/dynamic_text/locals_setter.rb
Instance Method Summary collapse
- #get_dynamic_locals(resource, attribute, opts = {}) ⇒ Object
-
#get_editable_locals(resource, attribute, opts = {}) ⇒ Object
PT.
Instance Method Details
#get_dynamic_locals(resource, attribute, opts = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/dynamic_text/locals_setter.rb', line 2 def get_dynamic_locals(resource, attribute, opts={}) locals.merge!(opts).tap do |locals| locals[:resource] = resource locals[:attribute] = attribute locals[:resource_id] = resource.id locals[:value] = resource.send(attribute) locals[:resource_scope] ||= default_resource_scope locals[:placeholder] ||= default_placeholder locals[:resource_type] ||= default_resource_type locals[:resource_route] ||= default_resource_route locals[:dynamic_tag] ||= default_dynamic_tag end end |
#get_editable_locals(resource, attribute, opts = {}) ⇒ Object
PT
16 17 18 19 20 21 |
# File 'lib/dynamic_text/locals_setter.rb', line 16 def get_editable_locals(resource, attribute, opts={}) get_dynamic_locals(resource, attribute, opts).tap do |locals| locals[:url] ||= default_url locals[:js_key] ||= default_js_key end end |