Class: PhilLocator::Barangay

Inherits:
ActiveYaml::Base
  • Object
show all
Includes:
ActiveHash::Associations
Defined in:
app/models/phil_locator/barangay.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'app/models/phil_locator/barangay.rb', line 21

def method_missing(method_name, *args, &block)
  case method_name.to_sym
  when :city
    PhilLocator::City.find_by(city_code: urbanRuralCode)
  when :municipality
    PhilLocator::Municipality.find_by(municipality_code: urbanRuralCode)
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(_method_name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/phil_locator/barangay.rb', line 32

def respond_to_missing?(_method_name, _include_private = false)
  true
end

#typeObject



17
18
19
# File 'app/models/phil_locator/barangay.rb', line 17

def type
  self[:urbanRural].upcase == "U" ? "urban" : "rural"
end