Module: AddresslogicRails::ClassMethods
- Defined in:
- lib/addresslogic_rails.rb
Instance Attribute Summary collapse
-
#addresslogic_options ⇒ Object
Returns the value of attribute addresslogic_options.
Instance Method Summary collapse
-
#apply_addresslogic(options = {}) ⇒ Object
Mixes in useful methods for handling addresses.
Instance Attribute Details
#addresslogic_options ⇒ Object
Returns the value of attribute addresslogic_options.
5 6 7 |
# File 'lib/addresslogic_rails.rb', line 5 def @addresslogic_options end |
Instance Method Details
#apply_addresslogic(options = {}) ⇒ Object
Mixes in useful methods for handling addresses.
Options
-
fields:
array of fields (default: [:street1, :street2, [:city, [:state, :zip]], :country]) -
namespace:
prefixes fields names with this, great for use with composed_of in ActiveRecord.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/addresslogic_rails.rb', line 13 def apply_addresslogic( = {}) n = [:namespace] [:fields] ||= [ "#{n}street1".to_sym, "#{n}street2".to_sym, ["#{n}city".to_sym, ["#{n}state".to_sym, "#{n}zip".to_sym]], "#{n}country".to_sym ] self. = end |