Class: ActiveAdmin::Views::LatlngProxy

Inherits:
FormtasticProxy
  • Object
show all
Defined in:
lib/activeadmin/views/latlng_proxy.rb

Instance Method Summary collapse

Instance Method Details

#build(_, *args, &_block) ⇒ Object



4
5
6
# File 'lib/activeadmin/views/latlng_proxy.rb', line 4

def build(_, *args, &_block)
  @lang, @id_lat, @id_lng, @height, @loading_map, @api_key, @default_lat, @default_lng, @map_zoom = *args
end

#keyObject



8
9
10
# File 'lib/activeadmin/views/latlng_proxy.rb', line 8

def key
  @api_key ? "&#{@api_key_name}=#{@api_key}" : ''
end

#loading_map_codeObject



16
17
18
# File 'lib/activeadmin/views/latlng_proxy.rb', line 16

def loading_map_code
  @loading_map ? script_html : ''
end

#script_htmlObject



12
13
14
# File 'lib/activeadmin/views/latlng_proxy.rb', line 12

def script_html
  @script_html % [@lang, key]
end

#to_sObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/activeadmin/views/latlng_proxy.rb', line 20

def to_s
  template = File.read(File.expand_path("../templates/#{@template_name}", __FILE__))
  variables = {
    loading_map_code: loading_map_code,
    height: @height,
    id_lat: @id_lat,
    id_lng: @id_lng,
    map_zoom: @map_zoom,
    default_lat: @default_lat,
    default_lng: @default_lng
  }

  render_template_with_hash(template, variables)
end