Module: DataMapper::Address::Preferred::ClassMethods
- Defined in:
- lib/dm-address/preferred.rb
Overview
class << self
Instance Method Summary collapse
-
#preferred_address(method_name) ⇒ Object
Setup a preferred address, including +method_name_id property.
Instance Method Details
#preferred_address(method_name) ⇒ Object
Setup a preferred address, including +method_name_id property
Parameters
- method_name<~to_s>
-
Name of method used to access the preferred address.
41 42 43 44 45 46 47 48 |
# File 'lib/dm-address/preferred.rb', line 41 def preferred_address(method_name) property("#{method_name}_id".to_sym, Integer) define_method(method_name) do self.addresses.get(attribute_get("#{method_name}_id")) || self.addresses.first end end |