Module: Pinpoint::ModelSupport
- Defined in:
- lib/pinpoint/model_support.rb
Class Method Summary collapse
-
.define_address_accessors(object, options = {}) ⇒ Object
Private: Defines address accessors for a given object.
Class Method Details
.define_address_accessors(object, options = {}) ⇒ Object
Private: Defines address accessors for a given object.
object - The object to apply the accessors to options - A Hash of options to apply to the method call
:field_name - The String or Symbol representing the name of the
field pair to create (eg: #venue and #venue=).
:prefix - If set, then all fields which make up the Address
will be prefixed with that string (eg: #venue_city
instead of just #city) If you do not want field
names to be prefixed simply set it to false.
(defaults to the field name).
Example
# Without a Prefix
define_address_accessors my_object, field_name: :venue
# With a Prefix
define_address_accessors my_object, field_name: :address,
prefix: :venue
Returns nothing
31 32 33 34 35 36 37 38 39 |
# File 'lib/pinpoint/model_support.rb', line 31 def self.define_address_accessors(object, = {}) field_name = .fetch(:field_name) [:prefix] = .fetch(:prefix, field_name) [:address_fields] ||= find_address_fields(object, ) define_address_reader(object, ) define_address_setter(object, ) define_address_predicates(object, ) end |