logical_model 0.4.1 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/logical_model.rb +15 -6
- data/lib/typhoeus_fix/array_decoder.rb +1 -1
- data/logical_model.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/lib/logical_model.rb
CHANGED
@@ -75,7 +75,7 @@ class LogicalModel
|
|
75
75
|
DEFAULT_RETRIES = 3
|
76
76
|
|
77
77
|
class << self
|
78
|
-
attr_accessor :host, :
|
78
|
+
attr_accessor :host, :resource_path, :api_key, :api_key_name,
|
79
79
|
:timeout, :retries,
|
80
80
|
:use_api_key, :enable_delete_multiple,
|
81
81
|
:json_root, :log_path
|
@@ -86,6 +86,14 @@ class LogicalModel
|
|
86
86
|
def use_api_key; @use_api_key ||= false; end
|
87
87
|
def delete_multiple_enabled?; @enable_delete_multiple ||= false; end
|
88
88
|
|
89
|
+
def hydra
|
90
|
+
@@hydra
|
91
|
+
end
|
92
|
+
|
93
|
+
def hydra=(hydra)
|
94
|
+
@@hydra = hydra
|
95
|
+
end
|
96
|
+
|
89
97
|
def validates_associated(*associations)
|
90
98
|
associations.each do |association|
|
91
99
|
validates_each association do |record, attr, value|
|
@@ -251,10 +259,11 @@ class LogicalModel
|
|
251
259
|
end
|
252
260
|
end
|
253
261
|
|
254
|
-
|
262
|
+
# @param params [Hash] parameters to be sent to service
|
263
|
+
def update(params)
|
255
264
|
run_callbacks :save do
|
256
265
|
run_callbacks :update do
|
257
|
-
_update(
|
266
|
+
_update(params)
|
258
267
|
end
|
259
268
|
end
|
260
269
|
|
@@ -483,13 +492,13 @@ class LogicalModel
|
|
483
492
|
#
|
484
493
|
# Usage:
|
485
494
|
# @person.update(params[:person])
|
486
|
-
def _update(
|
495
|
+
def _update(params)
|
487
496
|
|
488
|
-
self.attributes =
|
497
|
+
self.attributes = params[self.json_root]
|
489
498
|
|
490
499
|
return false unless valid?
|
491
500
|
|
492
|
-
params = self.class.merge_key(
|
501
|
+
params = self.class.merge_key(params)
|
493
502
|
|
494
503
|
response = nil
|
495
504
|
Timeout::timeout(self.class.timeout/1000) do
|
@@ -39,7 +39,7 @@ class Hash
|
|
39
39
|
# @return [TrueClass]
|
40
40
|
def im_an_array_typhoeus_encoded?
|
41
41
|
return false if self.empty?
|
42
|
-
self.keys.sort == (0...self.keys.size).map{|i|i
|
42
|
+
self.keys.map {|k| k.to_i}.sort == (0...self.keys.size).map {|i| i}
|
43
43
|
end
|
44
44
|
|
45
45
|
# If the hash is an array encoded by typhoeus an array is returned
|
data/logical_model.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "logical_model"
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dwayne Macgowan"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-12-21"
|
13
13
|
s.description = "LogicalModel allows to use a resource as a model. It is based on web presentation http://www.slideshare.net/ihower/serviceoriented-design-and-implement-with-rails3"
|
14
14
|
s.email = "dwaynemac@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logical_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -347,7 +347,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
347
347
|
version: '0'
|
348
348
|
segments:
|
349
349
|
- 0
|
350
|
-
hash:
|
350
|
+
hash: 207713501
|
351
351
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
352
352
|
none: false
|
353
353
|
requirements:
|