transcriber 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ class Root < Transcriber::Resource
5
5
  end
6
6
 
7
7
  class Item < Transcriber::Resource
8
- property :id
8
+ properties :id, :name
9
9
  end
10
10
 
11
11
  @root = Root.parse({item: {id: 2000}}).first
@@ -0,0 +1,11 @@
1
+ $:.push 'lib'; require 'transcriber'
2
+
3
+ class Customer < Transcriber::Resource
4
+ property :login
5
+ property :name
6
+ end
7
+
8
+ @root = Customer.new(login: 'jackiechan2010')
9
+
10
+ puts "root.to_input: #{@root.to_input(without_nil: true)}"
11
+ puts "root: #{@root.inspect}"
@@ -6,7 +6,8 @@ module Transcriber
6
6
 
7
7
  keys_to_input(options).each do |key|
8
8
  value = __send__(key.name)
9
- input.merge! key.to_input(value, self, options.fetch(key.name, {}))
9
+ key_options = options.fetch(key.name, {without_nil: options[:without_nil]})
10
+ input.merge! key.to_input(value, self, key_options)
10
11
  end
11
12
 
12
13
  input.with_indifferent_access
@@ -18,6 +19,10 @@ module Transcriber
18
19
  self.class.keys.clone.tap do |keys|
19
20
  keys.reject! {|k| k.kind_of?(Relation)}
20
21
  keys.reject! {|k| Array(options[:without]).include?(k.name)}
22
+
23
+ keys.reject! do |key|
24
+ __send__(key.name).nil? and options[:without_nil]
25
+ end
21
26
  end
22
27
  end
23
28
  end
@@ -24,12 +24,12 @@ module Transcriber
24
24
  def to_input(value, resource, options = {})
25
25
  return {} if value.nil?
26
26
  fields ? to_multiple_input(value, options)
27
- : to_single_input(value)
27
+ : to_single_input(value, options)
28
28
  end
29
29
 
30
30
  private
31
31
 
32
- def to_single_input(value)
32
+ def to_single_input(value, options)
33
33
  input = {}
34
34
  path = input_path
35
35
 
@@ -1,3 +1,3 @@
1
1
  module Transcriber
2
- VERSION = "0.0.23"
2
+ VERSION = "0.0.24"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transcriber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2011-09-26 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- requirement: &70275740826440 !ruby/object:Gem::Requirement
18
+ requirement: &70316681633680 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '3.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70275740826440
26
+ version_requirements: *70316681633680
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n
29
- requirement: &70275740825880 !ruby/object:Gem::Requirement
29
+ requirement: &70316681633180 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0.5'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70275740825880
37
+ version_requirements: *70316681633180
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
40
- requirement: &70275740825360 !ruby/object:Gem::Requirement
40
+ requirement: &70316681632720 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '2.6'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *70275740825360
48
+ version_requirements: *70316681632720
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: guard
51
- requirement: &70275740824880 !ruby/object:Gem::Requirement
51
+ requirement: &70316681632260 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0.5'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *70275740824880
59
+ version_requirements: *70316681632260
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: guard-rspec
62
- requirement: &70275740824400 !ruby/object:Gem::Requirement
62
+ requirement: &70316681631760 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0.4'
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *70275740824400
70
+ version_requirements: *70316681631760
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: growl
73
- requirement: &70275740823940 !ruby/object:Gem::Requirement
73
+ requirement: &70316681631280 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ~>
@@ -78,7 +78,7 @@ dependencies:
78
78
  version: '1.0'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *70275740823940
81
+ version_requirements: *70316681631280
82
82
  description: ''
83
83
  email:
84
84
  - victorcrodrigues@gmail.com
@@ -133,6 +133,7 @@ files:
133
133
  - examples/to_input/with_field_path.rb
134
134
  - examples/to_input/with_fields.rb
135
135
  - examples/to_input/without_key.rb
136
+ - examples/to_input/without_nil.rb
136
137
  - lib/transcriber.rb
137
138
  - lib/transcriber/configuration.rb
138
139
  - lib/transcriber/resource.rb