rpc-mapper 0.1.1 → 0.1.2
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.
@@ -7,6 +7,11 @@ module RPCMapper::Adapters
|
|
7
7
|
|
8
8
|
attr_reader :last_response
|
9
9
|
|
10
|
+
def initialize(*args)
|
11
|
+
super
|
12
|
+
self.config[:primary_key] ||= :id
|
13
|
+
end
|
14
|
+
|
10
15
|
def write(object)
|
11
16
|
params = build_params_from_attributes(object)
|
12
17
|
object.new_record? ? post_http(object, params) : put_http(object, params)
|
@@ -65,6 +70,7 @@ module RPCMapper::Adapters
|
|
65
70
|
def build_params_from_attributes(object)
|
66
71
|
if self.config[:post_body_wrapper]
|
67
72
|
params = self.config[:default_options] || {}
|
73
|
+
params.merge!(object.write_options[:default_options]) if object.write_options.is_a?(Hash) && object.write_options[:default_options].is_a?(Hash)
|
68
74
|
|
69
75
|
object.attributes.each do |attribute, value|
|
70
76
|
params.merge!({"#{self.config[:post_body_wrapper]}[#{attribute}]" => value})
|
@@ -78,7 +84,7 @@ module RPCMapper::Adapters
|
|
78
84
|
|
79
85
|
def build_uri(object, method)
|
80
86
|
url = [self.config[:host].gsub(%r{/$}, ''), self.config[:service]]
|
81
|
-
url << object.
|
87
|
+
url << object.send(self.config[:primary_key]) unless object.new_record?
|
82
88
|
uri = URI.parse "#{url.join('/')}#{self.config[:format]}"
|
83
89
|
|
84
90
|
# TRP: method DELETE has no POST body so we have to append any default options onto the query string
|
data/lib/rpc_mapper/base.rb
CHANGED
@@ -15,7 +15,7 @@ class RPCMapper::Base
|
|
15
15
|
include RPCMapper::Serialization
|
16
16
|
include RPCMapper::Scopes
|
17
17
|
|
18
|
-
attr_accessor :attributes, :new_record
|
18
|
+
attr_accessor :attributes, :new_record, :read_options, :write_options
|
19
19
|
alias :new_record? :new_record
|
20
20
|
|
21
21
|
class_inheritable_accessor :read_adapter, :write_adapter, :cacheable, :defined_attributes, :scoped_methods, :declared_associations
|
data/lib/rpc_mapper/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpc-mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Travis Petticrew
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-28 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|