acts_as_inheritable 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de7f7a195cd330508b532fbcbac354f6443e1aa9
4
- data.tar.gz: 1407afe5e36bdabca17bc62bf11513b284a3bc0a
3
+ metadata.gz: 6c22fde745dd8537cd5163ee6889ae36da28c38b
4
+ data.tar.gz: f53988647a6dbb2d2d921ad26d793aa59d15118e
5
5
  SHA512:
6
- metadata.gz: 078ad8bfebed70c26e90d6a166c7d03367f7450c9c2ff01f155e28e965ac05ff9de19ecae784bb362686e96b4461b18467b9497c3832242220c57cb80c440694
7
- data.tar.gz: 7bf5b0ef3d38faafb2ae3a3a16fd4c56dcac0a1eb52d38b7fb769bfe592b61b74c1255fac9ea0eb5d20e4d9ea15e712849baa71f6ef59924cc3a2e7d63779b82
6
+ metadata.gz: a90d7ba4eb931146859e04bef3b333dfdef7b8933b8f01bc80ab8ba332b792674fb91261ba3cc22bf3bb1cc84f9a63386f2b72c1fb8b4e0fc0e288dbc073767e
7
+ data.tar.gz: 46d59ea111cca4b0388c8be57384f8b5992977f11b9f66db67b7121c8c9e6eef5bdfd518da3716fb9d6b8051bfe0426240c7b579eec288c902921e0742fcedd7
@@ -20,7 +20,7 @@ module ActsAsInheritable
20
20
  # relations defined on `INHERITABLE_ASSOCIATIONS`. For each instance on
21
21
  # each relation it re-creates it.
22
22
  def inherit_relations(model_parent = send(:parent), current = self)
23
- if model_parent && model_parent.class.method_defined?(:inheritable_configuration)
23
+ if model_parent && model_parent.class.method_defined?(:inheritable_configuration) && model_parent.class::inheritable_configuration[:associations]
24
24
  model_parent.class::inheritable_configuration[:associations].each do |relation|
25
25
  parent_relation = model_parent.send(relation)
26
26
  relation_instances = parent_relation.respond_to?(:each) ? parent_relation : [parent_relation].compact
@@ -35,8 +35,9 @@ module ActsAsInheritable
35
35
  new_relation = relation_instance.dup
36
36
  belongs_to_associations_names = model_parent.class.reflect_on_all_associations(:belongs_to).collect(&:name)
37
37
  saved =
38
+ # Is a `belongs_to` association
38
39
  if belongs_to_associations_names.include?(relation.to_sym)
39
- # Is a `belongs_to` association
40
+ # You can define your own 'dup' method with a `duplicate!` signature
40
41
  new_relation = relation_instance.duplicate! if relation_instance.respond_to?(:duplicate!)
41
42
  current.send("#{relation}=", new_relation)
42
43
  current.save
@@ -70,7 +71,7 @@ module ActsAsInheritable
70
71
  end
71
72
 
72
73
  def inherit_attributes(force = false, not_force_for=[])
73
- if has_parent?
74
+ if has_parent? && self.class.inheritable_configuration[:attributes]
74
75
  # Attributes
75
76
  self.class.inheritable_configuration[:attributes].each do |attribute|
76
77
  current_val = send(attribute)
@@ -1,3 +1,3 @@
1
1
  module ActsAsInheritable
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_inheritable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esteban Arango Medina