Class: Marker::Helpers::FieldTag
- Inherits:
-
Object
- Object
- Marker::Helpers::FieldTag
- Defined in:
- lib/marker/helpers/field_tag.rb
Constant Summary collapse
- DEFAULT_MAP_ENGINE =
'google'.freeze
- DEFAULT_STYLE =
'width:800px;height:400px'.freeze
Instance Attribute Summary collapse
-
#engine ⇒ Object
readonly
Returns the value of attribute engine.
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(object_name, method_name, template, options = {}, html_options = {}) ⇒ FieldTag
constructor
Wrapper for render marker field Usage:.
- #input_options ⇒ Object
- #method_name ⇒ Object
- #object_name ⇒ Object
-
#to_s(locals = {}) ⇒ Object
:nodoc:.
Constructor Details
#initialize(object_name, method_name, template, options = {}, html_options = {}) ⇒ FieldTag
Wrapper for render marker field Usage:
marker = FieldTag.new(object_name, method_name, template, )
marker.to_s
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/marker/helpers/field_tag.rb', line 15 def initialize(object_name, method_name, template, = {}, = {}) #:nodoc: = { object_name: object_name, method_name: method_name }.merge!() @template = template = @engine = (.delete(:engine) || DEFAULT_MAP_ENGINE) @object = (.delete(:object) || @template.instance_variable_get("@#{object_name}")) [:id] ||= id end |
Instance Attribute Details
#engine ⇒ Object (readonly)
Returns the value of attribute engine.
4 5 6 |
# File 'lib/marker/helpers/field_tag.rb', line 4 def engine @engine end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
4 5 6 |
# File 'lib/marker/helpers/field_tag.rb', line 4 def end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
4 5 6 |
# File 'lib/marker/helpers/field_tag.rb', line 4 def object @object end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
4 5 6 |
# File 'lib/marker/helpers/field_tag.rb', line 4 def template @template end |
Instance Method Details
#id ⇒ Object
31 32 33 |
# File 'lib/marker/helpers/field_tag.rb', line 31 def id @id ||= @template.dom_id(@object, method_name) end |
#input_options ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/marker/helpers/field_tag.rb', line 35 def ||= { data: { marker: method_name, zoom: [:zoom] }, style: DEFAULT_STYLE }.merge!() end |
#method_name ⇒ Object
45 46 47 |
# File 'lib/marker/helpers/field_tag.rb', line 45 def method_name [:method_name] end |
#object_name ⇒ Object
49 50 51 |
# File 'lib/marker/helpers/field_tag.rb', line 49 def object_name [:object_name] end |
#to_s(locals = {}) ⇒ Object
:nodoc:
26 27 28 29 |
# File 'lib/marker/helpers/field_tag.rb', line 26 def to_s(locals = {}) #:nodoc: locals = { field: self }.merge!(locals) @template.render partial: "marker/#{@engine}", locals: locals end |