kentouzu 0.0.13 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.1.0
2
+
3
+ * Rails 4 compatibility.
4
+
1
5
  ## v0.0.13
2
6
 
3
7
  * Fixed 'all_with_reified_drafts` so that the most recent existing draft is pulled, overriding older drafts.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kentouzu (0.0.13)
4
+ kentouzu (0.1.0)
5
5
  activerecord (>= 3.0)
6
6
  railties (>= 3.0)
7
7
 
@@ -1,11 +1,10 @@
1
1
  require 'rails/generators'
2
2
  require 'rails/generators/migration'
3
- require 'rails/generators/active_record/migration'
3
+ require 'rails/generators/active_record'
4
4
 
5
5
  module Kentouzu
6
6
  class InstallGenerator < Rails::Generators::Base
7
7
  include Rails::Generators::Migration
8
- extend ActiveRecord::Generators::Migration
9
8
 
10
9
  source_root File.expand_path('../templates', __FILE__)
11
10
 
@@ -14,5 +13,9 @@ module Kentouzu
14
13
  def create_migration_file
15
14
  migration_template 'create_drafts.rb', 'db/migrate/create_drafts.rb'
16
15
  end
16
+
17
+ def self.next_migration_number(dirname)
18
+ ActiveRecord::Generators::Base.next_migration_number(dirname)
19
+ end
17
20
  end
18
21
  end
@@ -1,6 +1,4 @@
1
1
  class Draft < ActiveRecord::Base
2
- attr_accessible :item_type, :item_id, :event, :source_type, :source_id, :object
3
-
4
2
  belongs_to :item, :polymorphic => true
5
3
 
6
4
  belongs_to :source, :polymorphic => true
@@ -37,11 +37,19 @@ module Kentouzu
37
37
  class_attribute :drafts_association_name
38
38
  self.drafts_association_name = options[:drafts] || :drafts
39
39
 
40
- has_many self.drafts_association_name,
41
- :class_name => draft_class_name,
42
- :as => :item,
43
- :order => "#{Kentouzu.timestamp_field} ASC, #{self.draft_class_name.constantize.primary_key} ASC",
44
- :dependent => :destroy
40
+ if ActiveRecord::VERSION::STRING.to_f >= 4.0 # `has_many` syntax for specifying order uses a lambda in Rails 4
41
+ has_many self.drafts_association_name,
42
+ lambda { order("#{Kentouzu.timestamp_field} ASC, #{self.draft_class_name.constantize.primary_key} ASC") },
43
+ :class_name => draft_class_name,
44
+ :as => :item,
45
+ :dependent => :destroy
46
+ else
47
+ has_many self.drafts_association_name,
48
+ :class_name => draft_class_name,
49
+ :as => :item,
50
+ :order => "#{Kentouzu.timestamp_field} ASC, #{self.draft_class_name.constantize.primary_key} ASC",
51
+ :dependent => :destroy
52
+ end
45
53
 
46
54
  define_singleton_method "new_#{drafts_association_name.to_s}".to_sym do
47
55
  Draft.where(:item_type => self.name, :event => 'create')
@@ -1,3 +1,3 @@
1
1
  module Kentouzu
2
- VERSION = '0.0.13'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -1,5 +1,3 @@
1
1
  class Message < ActiveRecord::Base
2
- attr_accessible :first_name, :last_name, :subject, :body
3
-
4
2
  has_drafts :if => Proc.new { |b| self.first_name == 'Draft' }
5
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kentouzu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.1.0
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-12-09 00:00:00.000000000 Z
12
+ date: 2014-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -259,7 +259,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
259
259
  version: '0'
260
260
  segments:
261
261
  - 0
262
- hash: 3152904909740143463
262
+ hash: -333500455675358414
263
263
  required_rubygems_version: !ruby/object:Gem::Requirement
264
264
  none: false
265
265
  requirements:
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
268
  version: '0'
269
269
  segments:
270
270
  - 0
271
- hash: 3152904909740143463
271
+ hash: -333500455675358414
272
272
  requirements: []
273
273
  rubyforge_project: kentouzu
274
274
  rubygems_version: 1.8.25