Class: ActiveElement::Components::Json
- Inherits:
-
Object
- Object
- ActiveElement::Components::Json
- Defined in:
- lib/active_element/components/json.rb
Overview
Outputs a ‘<script>` tag and sets globally-available JSON data, available as `ActiveElement.jsonData.<key>`. Note key is camelized, so `foo_bar_baz` becomes `fooBarBaz`.
Instance Method Summary collapse
-
#initialize(controller, object:, key:) ⇒ Json
constructor
A new instance of Json.
- #locals ⇒ Object
- #template ⇒ Object
Constructor Details
#initialize(controller, object:, key:) ⇒ Json
Returns a new instance of Json.
8 9 10 11 12 |
# File 'lib/active_element/components/json.rb', line 8 def initialize(controller, object:, key:) @controller = controller @object = object @key = key end |
Instance Method Details
#locals ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/active_element/components/json.rb', line 18 def locals { controller: controller, object: object, key: ActiveElement::Components::Util.json_name(key) } end |
#template ⇒ Object
14 15 16 |
# File 'lib/active_element/components/json.rb', line 14 def template 'active_element/components/json' end |