printing_press 0.2.1 → 0.2.2

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -2,8 +2,7 @@ module PrintingPress
2
2
  module Controller
3
3
 
4
4
  def self.included(base)
5
- base.before_filter :set_printing_press_enabled_for_controller
6
- base.before_filter :setup_printing_press
5
+ base.prepend_before_filter :set_printing_press_enabled_for_controller, :setup_printing_press
7
6
  base.after_filter :disable_printing_press
8
7
  base.send :extend, ClassMethods
9
8
  end
@@ -15,27 +15,21 @@ module PrintingPress
15
15
  class_attribute :dependencies
16
16
  self.dependencies = options[:dependent_on] || []
17
17
 
18
- class_attribute :printing_press_enabled_for_model
18
+ class_attribute :printing_press_enabled_for_model
19
19
  end
20
20
 
21
21
  def printing_press_off
22
22
  self.printing_press_enabled_for_model = false
23
- self.reset_column_information
23
+ #self.table_name = self.reset_table_name
24
+ #self.reset_column_information
24
25
  end
25
26
 
26
27
  def printing_press_on
27
28
  self.printing_press_enabled_for_model = true
28
- self.reset_column_information
29
+ #self.table_name = self.published_table_name
30
+ #self.reset_column_information
29
31
  end
30
-
31
- def table_name
32
- if self.printing_press_enabled_for_model
33
- self.published_table_name
34
- else
35
- self.reset_table_name
36
- end
37
- end
38
-
32
+
39
33
  def drafts
40
34
  self.find_by_sql("SELECT o.* FROM #{self.reset_table_name} o, #{self.published_table_name} p WHERE (o.id = p.id AND o.updated_at != p.updated_at)") +
41
35
  self.find_by_sql("SELECT * FROM #{self.reset_table_name} WHERE id NOT IN (SELECT id FROM #{self.published_table_name}) GROUP BY id")
@@ -80,4 +74,26 @@ module PrintingPress
80
74
  end
81
75
 
82
76
  end
77
+ end
78
+
79
+ module ActiveRecord
80
+ class Base
81
+ class << self # Class methods
82
+ def quoted_table_name
83
+ if not defined?(@quoted_table_name) or @last_table_name_for_quoted != table_name
84
+ @quoted_table_name = connection.quote_table_name(table_name)
85
+ end
86
+
87
+ @last_table_name_for_quoted = @quoted_table_name
88
+ end
89
+
90
+ def arel_table
91
+ if not defined?(@quoted_table_name) or @last_table_name_for_arel != table_name
92
+ @arel_table = Arel::Table.new(table_name, arel_engine)
93
+ end
94
+
95
+ @last_table_name_for_arel = @arel_table
96
+ end
97
+ end
98
+ end
83
99
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: printing_press
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Edmond Leung
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-21 00:00:00 -05:00
18
+ date: 2012-01-01 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency