deb 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module Deb
2
2
  class Account < ActiveRecord::Base
3
- belongs_to :reference, polymorphic: true
3
+ belongs_to :accountable, polymorphic: true
4
4
  has_many :items
5
5
  has_many :transactions, through: :items
6
6
 
@@ -1,6 +1,6 @@
1
1
  module Deb
2
2
  class Transaction < ActiveRecord::Base
3
- belongs_to :reference, polymorphic: true
3
+ belongs_to :transactionable, polymorphic: true
4
4
  has_many :items
5
5
  has_many :accounts, through: :items
6
6
  has_many :debit_items, class_name: "Deb::Item", conditions: {kind: "debit"}
@@ -12,7 +12,7 @@ module Deb
12
12
  validate :credit_items_presence
13
13
  validate :proper_amounts
14
14
 
15
- attr_accessible :reference, :description
15
+ attr_accessible :transactionable, :description
16
16
 
17
17
  def self.start(&block)
18
18
  Docile.dsl_eval(Deb::Builder.new, &block).build
data/lib/deb/builder.rb CHANGED
@@ -26,8 +26,7 @@ module Deb
26
26
  end
27
27
 
28
28
  def build
29
- Deb::Transaction.new(description: @description, reference: @reference) do |t|
30
- t.reference = @reference
29
+ Deb::Transaction.new(description: @description, transactionable: @reference) do |t|
31
30
  credits.each do |account, amount|
32
31
  t.credit_items.build(account: account, amount: amount)
33
32
  end
data/lib/deb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Deb
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -4,20 +4,20 @@ class CreateDebTables < ActiveRecord::Migration
4
4
  t.string :name
5
5
  t.string :kind
6
6
  t.string :short_name, limit: 16
7
- t.references :reference, polymorphic: true
7
+ t.references :accountable, polymorphic: true
8
8
  t.boolean :contra
9
9
  t.decimal :current_balance, precision: 20, scale: 2, default: 0
10
10
  t.timestamps
11
11
  end
12
12
  add_index :deb_accounts, :short_name
13
- add_index :deb_accounts, [:reference_type, :reference_id, :kind], name: "deb_accounts_default"
13
+ add_index :deb_accounts, [:accountable_type, :accountable_id, :kind], name: "deb_accounts_default"
14
14
 
15
15
  create_table :deb_transactions do |t|
16
16
  t.string :description
17
- t.references :reference, polymorphic: true
17
+ t.references :transactionable, polymorphic: true
18
18
  t.timestamps
19
19
  end
20
- add_index :deb_transactions, [:reference_type, :reference_id], name: "deb_transactions_default"
20
+ add_index :deb_transactions, [:transactionable_type, :transactionable_id], name: "deb_transactions_default"
21
21
 
22
22
  create_table :deb_items do |t|
23
23
  t.string :kind
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-16 00:00:00.000000000 Z
12
+ date: 2013-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: -1261436476112288047
145
+ hash: -1408888727359197018
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  none: false
148
148
  requirements:
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  segments:
153
153
  - 0
154
- hash: -1261436476112288047
154
+ hash: -1408888727359197018
155
155
  requirements: []
156
156
  rubyforge_project:
157
157
  rubygems_version: 1.8.25