Sha256: 5be9e57170cf19ef5b6876c12418a7bcd68c9c6eb5cbdab281b51c26444c530b

Contents?: true

Size: 1.41 KB

Versions: 6

Compression:

Stored size: 1.41 KB

Contents

# encoding: utf-8
class MagicAddresses::Addressible < ActiveRecord::Base
  
  # =====> C O N S T A N T S <=============================================================== #
  PARAMS = [ :id, :owner_type, :owner_id, :_destroy, :address_attributes => [ :id, :street, :street_additional, :number, :postalcode, :city, :country, :country_code, :owner, :_destroy ] ]
  
  
  # =====> A S S O Z I A T I O N S <========================================================= #
  belongs_to :owner,      polymorphic: true
  belongs_to :address,    class_name: "MagicAddresses::Address",    foreign_key: :address_id
  
  
  # =====> A T T R I B U T E S <============================================================= #
  accepts_nested_attributes_for :address, allow_destroy: true
  
  
  # =====> C A L L B A C K S <=============================================================== #
  after_commit :log_some_stuff
  
  # =====>  P  R  I  V  A  T  E  !  <======================================================== # # # # # # # #
private
  
  def log_some_stuff
    Rails.logger.info "### ###"
    Rails.logger.info "### ###"
    Rails.logger.info "###  Triggered Addressible callback"
    Rails.logger.info "### ###"
    Rails.logger.info "### ###"
    puts "### ###"
    puts "### ###"
    puts "###  Triggered Addressible callback"
    puts "### ###"
    puts "### ###"
    self.address ? self.address.trigger_build_address_associations : true
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
magic_addresses-0.0.42 lib/app/models/magic_addresses/addressible.rb
magic_addresses-0.0.41 lib/app/models/magic_addresses/addressible.rb
magic_addresses-0.0.40 lib/app/models/magic_addresses/addressible.rb
magic_addresses-0.0.39 lib/app/models/magic_addresses/addressible.rb
magic_addresses-0.0.39.rc8 lib/app/models/magic_addresses/addressible.rb
magic_addresses-0.0.39.rc7 lib/app/models/magic_addresses/addressible.rb