Class: Magento::Region

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

Overview

Instance Attribute Summary

Attributes inherited from Base

#attributes

Class Method Summary collapse

Methods included from Base::ClassMethods

#api_path, #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

.find_by_country(iso) ⇒ Object



20
21
22
# File 'lib/magento/region.rb', line 20

def find_by_country(iso)
  list(iso)
end

.find_by_country_and_id(iso, id) ⇒ Object



24
25
26
# File 'lib/magento/region.rb', line 24

def find_by_country_and_id(iso, id)
  list(iso).select{ |r| r.id == id }.first
end

.find_by_country_iso_and_iso(country_iso, iso) ⇒ Object



28
29
30
# File 'lib/magento/region.rb', line 28

def find_by_country_iso_and_iso(country_iso, iso)
  list(country_iso).select{ |r| r.code == iso }.first
end

.list(*args) ⇒ Object

directory_region.list List of regions in specified country

Return: array

Arguments:

string $country - Country code in ISO2 or ISO3



13
14
15
16
17
18
# File 'lib/magento/region.rb', line 13

def list(*args)
  results = commit("list", *args)
  results.collect do |result|
    new(result)
  end
end