drafts 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/drafts.rb +2 -2
- data/lib/drafts/{drafts_manager.rb → draft_methods.rb} +4 -4
- data/lib/railtie.rb +2 -11
- metadata +2 -2
data/lib/drafts.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module DraftsMethods
|
2
2
|
def self.included base
|
3
3
|
base.class_exec do
|
4
4
|
extend BaseClassMethods
|
@@ -7,8 +7,8 @@ module DraftsManagerMethods
|
|
7
7
|
|
8
8
|
module BaseClassMethods
|
9
9
|
def has_drafts
|
10
|
-
include
|
11
|
-
extend
|
10
|
+
include DraftsMethods::InstanceMethods
|
11
|
+
extend DraftsMethods::ClassMethods
|
12
12
|
attr_accessor :draft_id
|
13
13
|
attr_accessible :draft_id
|
14
14
|
after_create :clear_draft
|
@@ -21,7 +21,7 @@ module DraftsManagerMethods
|
|
21
21
|
draft = Draft.find_by_id(self.draft_id) || Draft.new
|
22
22
|
attrs = self.attributes.clone.delete_if { |key, value| self.class.accessible_attributes.deny?(key) }
|
23
23
|
cache_attrs = {}
|
24
|
-
attrs.each { |attr, val| cache_attrs[attr + "_cache"] = self.send(attr + "_cache") if self.send(attr).is_a?(CarrierWave::Uploader::Base) }
|
24
|
+
attrs.each { |attr, val| cache_attrs[attr + "_cache"] = self.send(attr + "_cache") if defined?(CarrierWave) && self.send(attr).is_a?(CarrierWave::Uploader::Base) }
|
25
25
|
draft.data = attrs.merge cache_attrs
|
26
26
|
draft.name = self.to_s
|
27
27
|
draft.target_type = self.class.name
|
data/lib/railtie.rb
CHANGED
@@ -1,11 +1,2 @@
|
|
1
|
-
require "
|
2
|
-
|
3
|
-
module DraftsManager
|
4
|
-
|
5
|
-
class Railtie < Rails::Railtie
|
6
|
-
initializer "drafts init" do
|
7
|
-
ActionView::Base.send :include, DraftsManagerMethods
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
1
|
+
require "drafts/draft_methods"
|
2
|
+
ActiveRecord::Base.send :include, DraftsMethods
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drafts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -19,7 +19,7 @@ extensions: []
|
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
21
|
- README
|
22
|
-
- lib/drafts/
|
22
|
+
- lib/drafts/draft_methods.rb
|
23
23
|
- lib/drafts.rb
|
24
24
|
- lib/railtie.rb
|
25
25
|
homepage: http://github.com/lxkuz/draft
|