class Decidim::Map::Frontend::Builder
A general builder for any functionality needed for the views. Provides all the necessary functionality to display and initialize the front-end elements related to the given map utility.
Attributes
Public Class Methods
Initializes the map builder instance.
@param template [ActionView::Template] The template within which the
map is displayed.
@param options [Hash] Extra options for the builder object.
# File lib/decidim/map/frontend.rb, line 44 def initialize(template, options) @template = template @options = options end
Public Instance Methods
Displays the necessary front-end JavaScript assets for the map element.
@return [String, nil ] The map element's JavaScript assets markup for
the view or nil if there are no JavaScript assets.
# File lib/decidim/map/frontend.rb, line 61 def javascript_snippets; end
Displays the necessary front-end stylesheet assets for the map element.
@return [String, nil] The map element's stylesheet assets markup for
the view or nil if there are no stylesheet assets.
# File lib/decidim/map/frontend.rb, line 54 def stylesheet_snippets; end
Protected Instance Methods
Converts a hash with Ruby-style key names (snake_case) to JS-style key names (camelCase).
@param [Hash] The original hash with Ruby-style hash keys in
snake_case format.
@return [Hash] The resulting hash with JS-style hash keys in camelCase
format.
# File lib/decidim/map/frontend.rb, line 86 def hash_to_js(hash) hash.map do |key, value| value = hash_to_js(value) if value.is_a?(Hash) value = value.call(self) if value.respond_to?(:call) [key.to_s.camelize(:lower), value] end.to_h end
Returns the options hash that will be passed to the map element as a JSON encoded data attribute. These configurations can be used to pass information to the front-end map functionality, e.g. about the tile layer configurations and markers data.
@return [Hash] The configurations passed to the map element's data
attribute.
# File lib/decidim/map/frontend.rb, line 74 def view_options hash_to_js(options) end