Module: FreightKit::Carriers
Instance Attribute Summary collapse
-
#registered ⇒ Object
readonly
Returns the value of attribute registered.
Instance Method Summary collapse
Instance Attribute Details
#registered ⇒ Object (readonly)
Returns the value of attribute registered.
7 8 9 |
# File 'lib/freight_kit/carriers.rb', line 7 def registered @registered end |
Instance Method Details
#all ⇒ Object
16 17 18 |
# File 'lib/freight_kit/carriers.rb', line 16 def all FreightKit::Carriers.registered.map { |name| FreightKit.const_get(name) } end |
#find(name) ⇒ Object
20 21 22 |
# File 'lib/freight_kit/carriers.rb', line 20 def find(name) all.find { |c| c.name.downcase == name.to_s.downcase } or raise NameError, "unknown carrier #{name}" end |
#register(class_name, autoload_require) ⇒ Object
11 12 13 14 |
# File 'lib/freight_kit/carriers.rb', line 11 def register(class_name, autoload_require) FreightKit.autoload(class_name, autoload_require) registered << class_name end |