Module: Osgb::ClassMethods

Defined in:
lib/osgb/has_gridref.rb

Instance Method Summary collapse

Instance Method Details

#has_gridref(name, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/osgb/has_gridref.rb', line 13

def has_gridref name, options = {}
  include Osgb::InstanceMethods
  self.osgb_options = {
    :lat => 'lat',
    :lng => 'lng',
    :gridref => 'gridref',
    :validation => false,
    :conversion => true
  }.merge(options)
  before_validation :convert_between_gridref_and_latlng if osgb_options[:conversion]
  validates :must_have_location if osgb_options[:validation]
end