naranya_ecm-sdk 0.0.30 → 0.0.31
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa9acc400aae110158ac9b6cf303ba9f83a68665
|
4
|
+
data.tar.gz: 4279705e4e548df06969b369453089bd8173cf3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f2ccd99f062a6bee18b33af21f0942fed31d18f5f8a24e8e3ed1422b416d6991f2da682a96278bc69479a2f169f68dbf192b8b3f26dd68c8bbb3e4131482aca
|
7
|
+
data.tar.gz: 52b2859cae8701e6e7bccd776e82e5b018ec72d2cf145f49be8f609c14ec6b27725f7bb78429479b33de8f9cf399ba9eff8da70b0af869bdd6bc280ab7729313
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
require 'naranya_ecm/rest/relation'
|
3
|
+
|
4
|
+
module NaranyaEcm::Rest
|
5
|
+
class AssociationRelation < Relation
|
6
|
+
attr_reader :foreign_key_name, :foreign_key_value
|
7
|
+
|
8
|
+
def initialize(given_klass, given_foreign_key_name, given_foreign_key_value)
|
9
|
+
|
10
|
+
raise ArgumentError unless given_foreign_key_name.present?
|
11
|
+
|
12
|
+
@foreign_key_name, @foreign_key_value = given_foreign_key_name, given_foreign_key_value
|
13
|
+
|
14
|
+
super(given_klass, foreign_key_name => foreign_key_value)
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def fetch_from_server
|
19
|
+
foreign_key_value.present? ? super : []
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -47,7 +47,8 @@ module NaranyaEcm::Rest
|
|
47
47
|
foreign_key = (self.class.name.demodulize.underscore + '_id').to_sym
|
48
48
|
value = self.instance_variable_set(
|
49
49
|
"@#{name}".to_sym,
|
50
|
-
reflection.associated_class.where(foreign_key => self.id)
|
50
|
+
# reflection.associated_class.where(foreign_key => self.id)
|
51
|
+
AssociationRelation.new(reflection.associated_class, reflection.foreign_key, self.id)
|
51
52
|
)
|
52
53
|
end
|
53
54
|
value
|
@@ -56,7 +57,7 @@ module NaranyaEcm::Rest
|
|
56
57
|
# Define the setter
|
57
58
|
klass.send :define_method, "#{name}=".to_sym do |new_value|
|
58
59
|
reflection = self.class.reflect_on_association(name)
|
59
|
-
relation =
|
60
|
+
relation = AssociationRelation.new(reflection.associated_class, reflection.foreign_key, self.id)
|
60
61
|
|
61
62
|
relation.load new_value unless new_value.nil?
|
62
63
|
|
data/lib/naranya_ecm-sdk.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: naranya_ecm-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Quintanilla
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/naranya_ecm/models/content_version.rb
|
178
178
|
- lib/naranya_ecm/models/download_authorization.rb
|
179
179
|
- lib/naranya_ecm/models/media_resource.rb
|
180
|
+
- lib/naranya_ecm/rest/association_relation.rb
|
180
181
|
- lib/naranya_ecm/rest/associations.rb
|
181
182
|
- lib/naranya_ecm/rest/client.rb
|
182
183
|
- lib/naranya_ecm/rest/errors.rb
|