active_content 0.1.0 → 0.1.1
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 +4 -4
- data/lib/active_content/models/attachment.rb +1 -0
- data/lib/active_content/models/content.rb +4 -0
- data/lib/active_content/models/metum.rb +1 -0
- data/lib/active_content/models/profile.rb +1 -0
- data/lib/active_content/models/relation.rb +1 -0
- data/lib/active_content/models/taxonomization.rb +1 -0
- data/lib/active_content/models/taxonomy.rb +4 -0
- data/lib/active_content/models/template.rb +1 -0
- data/lib/active_content/models/upload.rb +4 -0
- data/lib/active_content/profileable.rb +19 -4
- data/lib/active_content/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95694815bebd13b3b30d8b1d065d6b04dce20877
|
4
|
+
data.tar.gz: 6cc2f2055d69201c469dafd1c8cac6e989b57930
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb88e592627b511a9a56641cb1ff48e7a88fbb22ba3446fc7fe588c92850ee3d8379163b92aada99a2afb5e905d05934befb04b209679ec550f33537cfba09f8
|
7
|
+
data.tar.gz: 57618528440456b8cfaf98a388115dc1d425b247185fb318670f4c97a7bbc7f91152bec1fb72abf169c0e123f7c74fcdde4cd709ef020e616ffc70e2c9ddf516
|
@@ -3,18 +3,33 @@ module ActiveContent
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
class_methods do
|
6
|
-
def has_profile
|
6
|
+
def has_profile(options={})
|
7
7
|
include ActiveDelegate
|
8
8
|
|
9
9
|
has_one :profile, as: :profileable, class_name: 'ActiveContent::Profile', autosave: true, dependent: :destroy
|
10
|
-
delegate_attributes to: :profile, allow_nil: true
|
10
|
+
delegate_attributes options.except(:to).merge(to: :profile, allow_nil: true)
|
11
|
+
|
12
|
+
before_save do
|
13
|
+
prof_foreign = self.class.profiles_attribute_names.map(&:to_s)
|
14
|
+
prof_current = prof_foreign.map { |n| send(n) }
|
15
|
+
prof_default = self.class.column_defaults.select { |n, _d| prof_foreign.include?(n) }.values
|
16
|
+
prof_changes = (prof_current - prof_default).reject(&:blank?)
|
17
|
+
|
18
|
+
if prof_changes.empty?
|
19
|
+
self.profile = nil
|
20
|
+
end
|
21
|
+
end
|
11
22
|
|
12
23
|
define_method :name do
|
13
|
-
|
24
|
+
if first_name or last_name
|
25
|
+
"#{first_name} #{last_name}".strip
|
26
|
+
end
|
14
27
|
end
|
15
28
|
|
16
29
|
define_method :gravatar do |size=48, default='mm'|
|
17
|
-
|
30
|
+
mail = try(:email)
|
31
|
+
hash = Digest::MD5::hexdigest(mail) unless mail.nil?
|
32
|
+
|
18
33
|
"https://www.gravatar.com/avatar/#{hash}?rating=PG&size=#{size}&default=#{default}"
|
19
34
|
end
|
20
35
|
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.
|
4
|
+
version: 0.1.1
|
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-
|
12
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|