Class: Magento::Country

Inherits:
Base
  • Object
show all
Defined in:
lib/magento/country.rb

Overview

Instance Attribute Summary

Attributes inherited from Base

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base::ClassMethods

#commit

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

.allObject



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

.listObject

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

#regionsObject



29
30
31
# File 'lib/magento/country.rb', line 29

def regions
  Magento::Region.find_by_country(self.iso2_code)
end