active_content 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d60c817352bd84ece447640c005b19fa387d2949
4
- data.tar.gz: cd81840e8c606e71f216a3aef698635f78f55bc6
3
+ metadata.gz: 3cb9c9ba1c2461a6a6756106db94041a75a53a6e
4
+ data.tar.gz: 65c8989b5e2732c26590c8d900caa081690f4935
5
5
  SHA512:
6
- metadata.gz: a7f591a16993b72bb4c9a1f404bd08363f61c7c482db47861b7c663535bcb8aa5e64d8ac5d967f1d2b4e0bc154ace717788a1856e5079ff3459e380edf3f2a00
7
- data.tar.gz: 23d890828c76d054afa886cba0d61bb0c505b38e076e31533957d28590413f8136cf4d1ad7a9c98f0557dbbb4fccea63ca84a199426f9b259dddb09631eb28ac
6
+ metadata.gz: 4b738f0b07040e6df0b15967d51e61047e9b752958ceb1a0f1328f14261c65b61bff0851f41637d9c5eacc8f14e76fa7838446a1b06cc008a0c8694857e4cf41
7
+ data.tar.gz: 21ea39f9a3bb162eabc391bbe5125e2992034f9d94fe56f9b1fde0b2ba92975e7b0ab66ecc8a014fb71cbf429730a1271bd3f72a96b63d73efaf71f8fed69a1d
@@ -15,6 +15,13 @@ module ActiveContent
15
15
 
16
16
  has_many options[:through], assoc_proc, assoc_opts
17
17
  has_many :"#{field}", options
18
+
19
+ define_method :"#{field}_urls" do |size=nil|
20
+ iv_name = "@#{field}_#{size}_urls"
21
+
22
+ instance_variable_get(iv_name) ||
23
+ instance_variable_set(iv_name, send(:"#{field}").map { |i| i.try(:file_url, size) })
24
+ end
18
25
  else
19
26
  options = defaults.merge(through: :"#{field}_attachment")
20
27
 
@@ -28,6 +35,13 @@ module ActiveContent
28
35
  define_method :"#{field}_id=" do |value|
29
36
  send :"#{field}=", Upload.find_by_id(value)
30
37
  end
38
+
39
+ define_method :"#{field}_url" do |size=nil|
40
+ iv_name = "@#{field}_#{size}_url"
41
+
42
+ instance_variable_get(iv_name) ||
43
+ instance_variable_set(iv_name, send(:"#{field}").try(:file_url, size))
44
+ end
31
45
  end
32
46
  end
33
47
  end
@@ -14,12 +14,7 @@ module ActiveContent
14
14
  delegate_attribute :value, cast_type, value_opts
15
15
 
16
16
  before_save do
17
- current = send(field)
18
- default = self.class.try(:"_attribute_#{field}_value_default")
19
-
20
- if current.blank? or current == default
21
- send :"#{field}_metum=", nil
22
- end
17
+ send(:"#{field}_metum=", nil) if send(field).blank?
23
18
  end
24
19
  end
25
20
  end
@@ -1,4 +1,4 @@
1
- class ActiveContent::Attachment < ApplicationRecord
1
+ class ActiveContent::Attachment < ActiveRecord::Base
2
2
  # Set table name
3
3
  self.table_name = 'attachments'
4
4
 
@@ -1,4 +1,4 @@
1
- class ActiveContent::Content < ApplicationRecord
1
+ class ActiveContent::Content < ActiveRecord::Base
2
2
  # Set table name
3
3
  self.table_name = 'contents'
4
4
 
@@ -1,4 +1,4 @@
1
- class ActiveContent::Metum < ApplicationRecord
1
+ class ActiveContent::Metum < ActiveRecord::Base
2
2
  # Set table name
3
3
  self.table_name = 'meta'
4
4
 
@@ -1,4 +1,4 @@
1
- class ActiveContent::Profile < ApplicationRecord
1
+ class ActiveContent::Profile < ActiveRecord::Base
2
2
  # Set table name
3
3
  self.table_name = 'profiles'
4
4
 
@@ -1,4 +1,4 @@
1
- class ActiveContent::Relation < ApplicationRecord
1
+ class ActiveContent::Relation < ActiveRecord::Base
2
2
  # Set table name
3
3
  self.table_name = 'relations'
4
4
 
@@ -1,4 +1,4 @@
1
- class ActiveContent::Taxonomization < ApplicationRecord
1
+ class ActiveContent::Taxonomization < ActiveRecord::Base
2
2
  # Set table name
3
3
  self.table_name = 'taxonomizations'
4
4
 
@@ -1,4 +1,4 @@
1
- class ActiveContent::Taxonomy < ApplicationRecord
1
+ class ActiveContent::Taxonomy < ActiveRecord::Base
2
2
  # Set table name
3
3
  self.table_name = 'taxonomies'
4
4
 
@@ -1,4 +1,4 @@
1
- class ActiveContent::Template < ApplicationRecord
1
+ class ActiveContent::Template < ActiveRecord::Base
2
2
  # Set table name
3
3
  self.table_name = 'templates'
4
4
 
@@ -1,4 +1,4 @@
1
- class ActiveContent::Upload < ApplicationRecord
1
+ class ActiveContent::Upload < ActiveRecord::Base
2
2
  # Set table name
3
3
  self.table_name = 'uploads'
4
4
 
@@ -1,3 +1,3 @@
1
1
  module ActiveContent
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_content
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olibia Tsati
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-11-15 00:00:00.000000000 Z
12
+ date: 2017-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord