tainbox 0.3.0 → 1.0.0

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: b30c8ebc0494c83dbc8606618d9284702b7d2699
4
- data.tar.gz: 2904be5c30aa7dd7b50dcf276a08e85701783fa1
3
+ metadata.gz: b459f82b88de885cb962e19571471ccb4a0d8af2
4
+ data.tar.gz: 1c3a37eb14e09eb5175714bbf4d1997d43b33d4b
5
5
  SHA512:
6
- metadata.gz: 18dd214bf56ba0fcb1b35e4c43076a9073d95b89bec4c2d59c9cb0295207dc056107f6d3e68724adb8793d0ea8d92a5611775b3426d42b53cd9dff135c4c6882
7
- data.tar.gz: b4993f9e45c0facd1bf9af8e763170fd9f4ff24799328e46a2070cacc949fefc91bd5feaae3796ebfaaa388135205e477f1e494081a8002e156eb4ed2afefb76
6
+ metadata.gz: 670ef55e0098aff940d338026dad216770a316fd56da3abec04d20d3f08033dd25d0f16532decd662eda2ae47c53547b8f45db01e8a4b11a79755279038bc51f
7
+ data.tar.gz: d6f9860bc73c8c79f9dafb1a06a270aaeaeb67b817efb2f19f0b4ca99d5d3c0c34dfb1e290887cbf54c1cadff078ea924ae415c4134b823bdb5988ea114be221
data/CHANGELOG.md CHANGED
@@ -24,3 +24,7 @@
24
24
  ## 0.3.0
25
25
 
26
26
  * String converter supports `strip` option to strip values
27
+
28
+ ## 1.0.0
29
+
30
+ * `as_json` support for tainbox objects
data/README.md CHANGED
@@ -107,6 +107,22 @@ Tainbox.define_converter(MyType) do
107
107
  end
108
108
  ```
109
109
 
110
+ ### `as_json`
111
+
112
+ ``` ruby
113
+ class Person
114
+ include Tainbox
115
+ attribute :name
116
+ attribute :age
117
+ end
118
+
119
+ person = Person.new(name: 'John', age: 20)
120
+
121
+ person.as_json # => { 'name' => 'John', 'age' => 20 }
122
+ person.as_json(only: :name) # => { 'name' => 'John' }
123
+ person.as_json(except: :name) # => { 'age' => 20 }
124
+ ```
125
+
110
126
  ### Suppressing tainbox initializer
111
127
 
112
128
  If you don't want to pollute your class with tainbox initializer you can do:
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/hash/keys'
2
+ require 'active_support/core_ext/object/json'
2
3
 
3
4
  require_relative 'extensions'
4
5
 
@@ -38,6 +39,10 @@ module Tainbox::InstanceMethods
38
39
  end
39
40
  end
40
41
 
42
+ def to_hash
43
+ attributes
44
+ end
45
+
41
46
  def attribute_provided?(attribute)
42
47
  tainbox_provided_attributes.include?(attribute.to_sym)
43
48
  end
@@ -1,3 +1,3 @@
1
1
  module Tainbox
2
- VERSION = '0.3.0'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tainbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Gubitskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-26 00:00:00.000000000 Z
11
+ date: 2016-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport