beef-has_assets 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/has_assets.gemspec +1 -2
- data/lib/has_assets.rb +28 -7
- data/rails/init.rb +1 -2
- metadata +1 -2
- data/lib/has_assets/has_assets.rb +0 -28
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.10
|
data/has_assets.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{has_assets}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.10"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Steve England"]
|
@@ -49,7 +49,6 @@ Gem::Specification.new do |s|
|
|
49
49
|
"lib/has_assets/custom_redcloth_tags.rb",
|
50
50
|
"lib/has_assets/flash_sesion_cookie_middleware.rb",
|
51
51
|
"lib/has_assets/geometry_crop.rb",
|
52
|
-
"lib/has_assets/has_assets.rb",
|
53
52
|
"lib/has_assets/imagescience_crop.rb",
|
54
53
|
"lib/has_assets/swfupload.rb",
|
55
54
|
"rails/init.rb",
|
data/lib/has_assets.rb
CHANGED
@@ -1,7 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
module Beef
|
2
|
+
module Has
|
3
|
+
module Assets
|
4
|
+
def self.included(base)
|
5
|
+
base.extend ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def has_assets
|
10
|
+
has_many :assetings, :as => :assetable, :dependent => :delete_all
|
11
|
+
has_many :assets, :through => :assetings, :order => 'assetings.id'
|
12
|
+
|
13
|
+
# Override the default asset_ids method
|
14
|
+
define_method("asset_ids=") do |new_value|
|
15
|
+
ids = (new_value || []).reject { |nid| nid.blank? }
|
16
|
+
ids.collect!{ |id| id.to_i}
|
17
|
+
logger.debug "ASSETS the same #{ids == self.asset_ids} | IDS #{ids} | #{self.asset_ids}"
|
18
|
+
return if ids == self.asset_ids
|
19
|
+
self.assets.clear
|
20
|
+
ids.each_index do |idx|
|
21
|
+
self.assets << Asset.find(ids[idx])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/rails/init.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beef-has_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve England
|
@@ -59,7 +59,6 @@ files:
|
|
59
59
|
- lib/has_assets/custom_redcloth_tags.rb
|
60
60
|
- lib/has_assets/flash_sesion_cookie_middleware.rb
|
61
61
|
- lib/has_assets/geometry_crop.rb
|
62
|
-
- lib/has_assets/has_assets.rb
|
63
62
|
- lib/has_assets/imagescience_crop.rb
|
64
63
|
- lib/has_assets/swfupload.rb
|
65
64
|
- rails/init.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Beef
|
2
|
-
module Has
|
3
|
-
module Assets
|
4
|
-
def self.included(base)
|
5
|
-
base.extend ClassMethods
|
6
|
-
end
|
7
|
-
|
8
|
-
module ClassMethods
|
9
|
-
def has_assets
|
10
|
-
has_many :assetings, :as => :assetable, :dependent => :delete_all
|
11
|
-
has_many :assets, :through => :assetings, :order => 'assetings.id'
|
12
|
-
|
13
|
-
# Override the default asset_ids method
|
14
|
-
define_method("asset_ids=") do |new_value|
|
15
|
-
ids = (new_value || []).reject { |nid| nid.blank? }
|
16
|
-
ids.collect!{ |id| id.to_i}
|
17
|
-
logger.debug "ASSETS the same #{ids == self.asset_ids} | IDS #{ids} | #{self.asset_ids}"
|
18
|
-
return if ids == self.asset_ids
|
19
|
-
self.assets.clear
|
20
|
-
ids.each_index do |idx|
|
21
|
-
self.assets << Asset.find(ids[idx])
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|