Module: Ropenlayer::ActsAs::Mapper::InstanceMethods

Defined in:
lib/ropenlayer/acts_as/mapper.rb

Instance Method Summary collapse

Instance Method Details

#build_ropenlayer_map(container_id, map_config = {}) ⇒ Object



91
92
93
94
95
96
# File 'lib/ropenlayer/acts_as/mapper.rb', line 91

def build_ropenlayer_map(container_id, map_config = {})
  config          = self.class.ropenlayer_mapper_config.merge(map_config)
  config          = set_map_localization(config)
  config          = parse_nodes(config)
  @ropenlayer_map = Ropenlayer::Openlayer::Map.new(container_id, config)
end

#ensure_localizable_modelObject

Ensure model can be localizable



105
106
107
108
# File 'lib/ropenlayer/acts_as/mapper.rb', line 105

def ensure_localizable_model
  error = "Model `#{ self.class }` is not localizable. To use this facility, latitude, longitude and zoom should be mapped to a valid instance methods"
  raise error unless self.class.methods.include?("localizable") and self.class.localizable
end

#ensure_mapper_modelObject

Ensure model acts_as_mapper



99
100
101
102
# File 'lib/ropenlayer/acts_as/mapper.rb', line 99

def ensure_mapper_model
  error = "Model `#{ self.class }` doesnt acts as map"
  raise error unless self.class.methods.include?("acts_as_mapper") and self.class.acts_as_mapper
end

#ropenlayer_map(options = {}) ⇒ Object

return ropenlayer_map instance or create a new one with the given data options can be override



84
85
86
87
88
# File 'lib/ropenlayer/acts_as/mapper.rb', line 84

def ropenlayer_map(options = {})
  container_id = options.delete(:container_id) || "#{ self.class.name.underscore }_ropenlayer_map"
  
  @ropenlayer_map.nil? ? build_ropenlayer_map(container_id, options) : @ropenlayer_map
end