has_moderated 1.0.rc7 → 1.0.rc8

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Add it to your project's Gemfile
7
7
 
8
- gem "has_moderated", ">=1.0.rc7"
8
+ gem "has_moderated", ">=1.0.rc8"
9
9
 
10
10
  and run
11
11
 
@@ -26,9 +26,9 @@ When upgrading, rerun the generator
26
26
 
27
27
  rails generate has_moderated:install
28
28
 
29
- If there is a new migration file and you have filename conflicts, remove the old one and apply the new one, in case the schema changed. This is especially important if you are upgrading from a previous version to v1.x.
29
+ If you are upgrading from a version lower than 1.0.x you need to remove the old create_moderations migration file.
30
30
 
31
- Before upgrading make sure you have reviewed and accepted/declined all current moderations first! This means the moderations table in database must be empty, otherwise the migration process will fail (on purpose). I suggest you modify the migration generated by has_moderated:install to first accept or discard all existing moderations, based on your preference - or do it in your administrative interface before deploying the upgrade.
31
+ Make sure you have reviewed and accepted/declined all current moderations before upgrading! This means the moderations table in database should be empty, otherwise the migration process might fail (on purpose).
32
32
 
33
33
  == Why use this instead of something like Papertrail?
34
34
 
@@ -136,7 +136,7 @@ The fake object described above has a nifty feature (1.0.rc7+) that allows you t
136
136
  preview.title = "Task 2"
137
137
  preview.update_moderation
138
138
  moderation.parsed_data # => {:attributes=>{"title"=>"Task 2"}}
139
- moderation.apply
139
+ moderation.accept
140
140
  Task.first.title # => "Task 2"
141
141
 
142
142
  === Get a real ActiveRecord preview
@@ -277,6 +277,8 @@ It is also possible you will encounter problems with some heavily customized ass
277
277
 
278
278
  This is just for my personal todo list...
279
279
 
280
+ perhaps can use .freeze for preview?
281
+
280
282
  improve functionality when rerunning has_moderated:install generator
281
283
 
282
284
  hm maybe has_moderated_association could be just a has_moderated_create on the assoc? just check stuff like if task_id is not nil or something. could be much easier to implement then
@@ -2,15 +2,25 @@ module HasModerated
2
2
  module Generators
3
3
  class InstallGenerator < ::Rails::Generators::Base
4
4
  desc "This generator installs files for has_moderated."
5
- source_root File.expand_path('../templates', __FILE__)
6
5
  include Rails::Generators::Migration
7
6
 
7
+ def self.source_root
8
+ @_has_moderated_source_root ||= File.expand_path("../templates", __FILE__)
9
+ end
10
+
8
11
  def files
9
- class_collisions 'Moderation'
12
+ # class_collisions 'Moderation'
10
13
  template 'moderation.rb', File.join('app/models', 'moderation.rb')
11
- migration_template 'migration.rb', 'db/migrate/create_moderations.rb'
12
14
  end
13
15
 
16
+ def create_migrations
17
+ Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
18
+ name = File.basename(filepath)
19
+ migration_template "migrations/#{name}", "db/migrate/#{name.gsub(/^\d+_/,'')}"
20
+ sleep 1
21
+ end
22
+ end
23
+
14
24
  private
15
25
  def self.next_migration_number(dirname) #:nodoc:
16
26
  if ActiveRecord::Base.timestamped_migrations
@@ -1,9 +1,5 @@
1
1
  module HasModerated
2
2
  module Common
3
- def self.included(base)
4
- base.send :include, InstanceMethods
5
- end
6
-
7
3
  def self.init(klass)
8
4
  unless klass.class_variable_defined? "@@moderation_disabled"
9
5
  klass.class_eval do
@@ -0,0 +1,14 @@
1
+ module HasModerated
2
+ class Railtie < Rails::Railtie
3
+ initializer "has_moderated.include_in_activerecord" do
4
+ ActiveSupport.on_load :active_record do
5
+ include HasModerated::Common::InstanceMethods
6
+ extend HasModerated::UserHooks::ClassMethods
7
+ extend HasModerated::Associations::Base::ClassMethods
8
+ extend HasModerated::ModeratedAttributes::ClassMethods
9
+ extend HasModerated::ModeratedCreate::ClassMethods
10
+ extend HasModerated::ModeratedDestroy::ClassMethods
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module HasModerated
2
- VERSION = "1.0.rc7"
2
+ VERSION = "1.0.rc8"
3
3
  end
data/lib/has_moderated.rb CHANGED
@@ -14,18 +14,4 @@ require 'has_moderated/moderated_create'
14
14
  require 'has_moderated/moderated_destroy'
15
15
 
16
16
  require 'has_moderated/carrier_wave'
17
-
18
- module HasModerated
19
- def self.included(base)
20
- HasModerated::Common::included(base)
21
- base.send :extend, HasModerated::UserHooks::ClassMethods
22
-
23
- # TODO: only include class methods that can be called, lazy load everything else
24
- base.send :extend, HasModerated::Associations::Base::ClassMethods
25
- base.send :extend, HasModerated::ModeratedAttributes::ClassMethods
26
- base.send :extend, HasModerated::ModeratedCreate::ClassMethods
27
- base.send :extend, HasModerated::ModeratedDestroy::ClassMethods
28
- end
29
- end
30
-
31
- ActiveRecord::Base.send :include, HasModerated
17
+ require 'has_moderated/railtie' if defined?(Rails)
@@ -70,3 +70,8 @@ Connecting to database specified by database.yml
70
70
  Connecting to database specified by database.yml
71
71
  Connecting to database specified by database.yml
72
72
  Connecting to database specified by database.yml
73
+ Connecting to database specified by database.yml
74
+ Connecting to database specified by database.yml
75
+ Connecting to database specified by database.yml
76
+ Connecting to database specified by database.yml
77
+ Connecting to database specified by database.yml