Class: Magento::Country
Overview
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .all ⇒ Object
- .find_by_id(id) ⇒ Object
- .find_by_iso(iso) ⇒ Object
-
.list ⇒ Object
directory_country.list Retrieve list of countries.
Instance Method Summary collapse
Methods included from Base::ClassMethods
Methods included from Base::InstanceMethods
#id, #id=, #initialize, #method_missing, #object_attributes=
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Magento::Base::InstanceMethods
Class Method Details
.all ⇒ Object
16 17 18 |
# File 'lib/magento/country.rb', line 16 def all list end |
.find_by_id(id) ⇒ Object
20 21 22 |
# File 'lib/magento/country.rb', line 20 def find_by_id(id) list.select{ |c| c.id == id }.first end |
.find_by_iso(iso) ⇒ Object
24 25 26 |
# File 'lib/magento/country.rb', line 24 def find_by_iso(iso) list.select{ |c| [c.iso2_code, c.iso3_code].include? iso }.first end |
.list ⇒ Object
directory_country.list Retrieve list of countries.
Return: array.
9 10 11 12 13 14 |
# File 'lib/magento/country.rb', line 9 def list results = commit("list", nil) results.collect do |result| new(result) end end |
Instance Method Details
#regions ⇒ Object
29 30 31 |
# File 'lib/magento/country.rb', line 29 def regions Magento::Region.find_by_country(self.iso2_code) end |