signatureio 0.0.2 → 0.0.3
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.
- data/lib/signatureio/document.rb +3 -3
- data/lib/signatureio/version.rb +1 -1
- data/lib/signatureio.rb +1 -2
- data/signatureio.gemspec +1 -0
- data/spec/signatureio/version_spec.rb +1 -1
- metadata +19 -5
- data/lib/signatureio/extensions/recursive_openstruct.rb +0 -28
- data/lib/signatureio/extensions/try.rb +0 -57
data/lib/signatureio/document.rb
CHANGED
@@ -5,17 +5,17 @@ module Signatureio
|
|
5
5
|
#
|
6
6
|
def self.create(attrs={})
|
7
7
|
response = Signatureio.request.post "documents.json", attrs
|
8
|
-
response.body
|
8
|
+
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.retrieve(id=nil)
|
12
12
|
response = Signatureio.request.get "documents/#{id}.json"
|
13
|
-
response.body
|
13
|
+
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.all
|
17
17
|
response = Signatureio.request.get "documents.json"
|
18
|
-
response.body
|
18
|
+
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/signatureio/version.rb
CHANGED
data/lib/signatureio.rb
CHANGED
data/signatureio.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: signatureio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: recursive-open-struct
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: pry
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,8 +122,6 @@ files:
|
|
106
122
|
- Rakefile
|
107
123
|
- lib/signatureio.rb
|
108
124
|
- lib/signatureio/document.rb
|
109
|
-
- lib/signatureio/extensions/recursive_openstruct.rb
|
110
|
-
- lib/signatureio/extensions/try.rb
|
111
125
|
- lib/signatureio/version.rb
|
112
126
|
- signatureio.gemspec
|
113
127
|
- spec/signatureio/document_spec.rb
|
@@ -128,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
142
|
version: '0'
|
129
143
|
segments:
|
130
144
|
- 0
|
131
|
-
hash: -
|
145
|
+
hash: -3720145876798221900
|
132
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
147
|
none: false
|
134
148
|
requirements:
|
@@ -137,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
151
|
version: '0'
|
138
152
|
segments:
|
139
153
|
- 0
|
140
|
-
hash: -
|
154
|
+
hash: -3720145876798221900
|
141
155
|
requirements: []
|
142
156
|
rubyforge_project:
|
143
157
|
rubygems_version: 1.8.23
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# https://gist.github.com/2710460
|
2
|
-
class Hash
|
3
|
-
# options:
|
4
|
-
# :exclude => [keys] - keys need to be symbols
|
5
|
-
def to_ostruct_recursive(options = {})
|
6
|
-
convert_to_ostruct_recursive(self, options)
|
7
|
-
end
|
8
|
-
|
9
|
-
def with_sym_keys
|
10
|
-
self.inject({}) { |memo, (k,v)| memo[k.to_sym] = v; memo }
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def convert_to_ostruct_recursive(obj, options)
|
16
|
-
result = obj
|
17
|
-
if result.is_a? Hash
|
18
|
-
result = result.dup.with_sym_keys
|
19
|
-
result.each do |key, val|
|
20
|
-
result[key] = convert_to_ostruct_recursive(val, options) unless options[:exclude].try(:include?, key)
|
21
|
-
end
|
22
|
-
result = OpenStruct.new result
|
23
|
-
elsif result.is_a? Array
|
24
|
-
result = result.map { |r| convert_to_ostruct_recursive(r, options) }
|
25
|
-
end
|
26
|
-
return result
|
27
|
-
end
|
28
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
class Object
|
2
|
-
# Invokes the method identified by the symbol +method+, passing it any arguments
|
3
|
-
# and/or the block specified, just like the regular Ruby <tt>Object#send</tt> does.
|
4
|
-
#
|
5
|
-
# *Unlike* that method however, a +NoMethodError+ exception will *not* be raised
|
6
|
-
# and +nil+ will be returned instead, if the receiving object is a +nil+ object or NilClass.
|
7
|
-
#
|
8
|
-
# If try is called without a method to call, it will yield any given block with the object.
|
9
|
-
#
|
10
|
-
# Please also note that +try+ is defined on +Object+, therefore it won't work with
|
11
|
-
# subclasses of +BasicObject+. For example, using try with +SimpleDelegator+ will
|
12
|
-
# delegate +try+ to target instead of calling it on delegator itself.
|
13
|
-
#
|
14
|
-
# ==== Examples
|
15
|
-
#
|
16
|
-
# Without +try+
|
17
|
-
# @person && @person.name
|
18
|
-
# or
|
19
|
-
# @person ? @person.name : nil
|
20
|
-
#
|
21
|
-
# With +try+
|
22
|
-
# @person.try(:name)
|
23
|
-
#
|
24
|
-
# +try+ also accepts arguments and/or a block, for the method it is trying
|
25
|
-
# Person.try(:find, 1)
|
26
|
-
# @people.try(:collect) {|p| p.name}
|
27
|
-
#
|
28
|
-
# Without a method argument try will yield to the block unless the receiver is nil.
|
29
|
-
# @person.try { |p| "#{p.first_name} #{p.last_name}" }
|
30
|
-
#--
|
31
|
-
# +try+ behaves like +Object#send+, unless called on +NilClass+.
|
32
|
-
def try(*a, &b)
|
33
|
-
if a.empty? && block_given?
|
34
|
-
yield self
|
35
|
-
else
|
36
|
-
__send__(*a, &b)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class NilClass
|
42
|
-
# Calling +try+ on +nil+ always returns +nil+.
|
43
|
-
# It becomes specially helpful when navigating through associations that may return +nil+.
|
44
|
-
#
|
45
|
-
# === Examples
|
46
|
-
#
|
47
|
-
# nil.try(:name) # => nil
|
48
|
-
#
|
49
|
-
# Without +try+
|
50
|
-
# @person && !@person.children.blank? && @person.children.first.name
|
51
|
-
#
|
52
|
-
# With +try+
|
53
|
-
# @person.try(:children).try(:first).try(:name)
|
54
|
-
def try(*args)
|
55
|
-
nil
|
56
|
-
end
|
57
|
-
end
|