Sha256: 6deefbf37eaaea39994a5260cce1a284275e7d2cab1253f72c1a0c7b39fc2985

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

module InvoiceBar
  module Billable
    module Associations
      module Base
        extend ActiveSupport::Concern

        included do
          attr_accessible :account_id, :user_id,
                          :address, :address_attributes,
                          :items_attributes

          delegate :city, :city_part, :extra_address_line, :postcode, :street, :street_number,
                   to: :user, prefix: true

          delegate :city, :city_part, :extra_address_line, :postcode, :street, :street_number,
                   to: :user_address, prefix: true

          delegate :city, :city_part, :extra_address_line, :postcode, :street, :street_number,
                   to: :address, prefix: true

          delegate :name, :bank_account_number, :swift, :iban,
                   to: :account, prefix: true

          belongs_to :account
          belongs_to :user

          has_one :address, as: :addressable, dependent: :destroy
          has_many :items, as: :itemable, dependent: :destroy

          accepts_nested_attributes_for :items, allow_destroy: true, reject_if: :all_blank
          accepts_nested_attributes_for :address, allow_destroy: true, reject_if: :all_blank

          validates :user_id, presence: true, numericality: true
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
invoice_bar-0.0.11 app/concerns/invoice_bar/billable/associations/base.rb
invoice_bar-0.0.10 app/concerns/invoice_bar/billable/associations/base.rb
invoice_bar-0.0.9 app/concerns/invoice_bar/billable/associations/base.rb
invoice_bar-0.0.8 app/concerns/invoice_bar/billable/associations/base.rb
invoice_bar-0.0.7 app/concerns/invoice_bar/billable/associations/base.rb