blueprinter 0.3.0 → 0.4.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
  SHA256:
3
- metadata.gz: 2924df0d9994662334f417cc9cda5b05863152bad025bb7193e19f95ec6d448b
4
- data.tar.gz: 8eb870216b6535ed26793b97d2b3cc0aaeec224894dbbf4e0582e9369a70a7e7
3
+ metadata.gz: '08abb9ba41c2c44993545fc879b4b94ab77394356f8cc82bc2fd8f11d37ad482'
4
+ data.tar.gz: d40666d3ed13b2bfca020a0ee37bde00876300ab856591b1e33d4cc6067f23c7
5
5
  SHA512:
6
- metadata.gz: ff5834c72d06aca41d2f2cf6d309015af5dea83ea66d008da8f5de980162676e0131612a6dfa2a93e5bd14f6deb82c39d8f96e468181bb57b30219f668a45128
7
- data.tar.gz: f716a6124b91d751c0f9bbdfd248f0b4ccedcd98548ed1572173d1166cfb2d912691f927e707499f0c113d1b62330340ce5f64198251899c404e0e83ff2de428
6
+ metadata.gz: 4353599cf5f1b1320ad8bd930c23bbf046258c7767f4e27ff2d07faedc28fd031d29166959e2303588ac96140e06881bf761e2918e9cf40db0abe941cc2cb5a7
7
+ data.tar.gz: da2c78ad5210456490af49493a2b9043fde2aa73bd1a0642e6f2264c4ac004200e8d3a3a4058ec66cd1014252c4fd3f901ae6a771411c9720f8c1490ab7199f8
@@ -1,3 +1,8 @@
1
+ ## 0.4.0 - 2018/05/02
2
+
3
+ * [FEATURE] Add `render_as_hash` which will output a hash instead of
4
+ a JSON String. See PR #76 by @amayer171 and Issue #73.
5
+
1
6
  ## 0.3.0 - 2018/04/05
2
7
 
3
8
  Sort of a breaking Change. Serializer classes has been renamed to Extractor. To upgrade, if you passed in a specific serializer to `field` or `identifier` such as:
@@ -131,6 +131,27 @@ module Blueprinter
131
131
  jsonify(prepare(object, view_name: view_name, local_options: options))
132
132
  end
133
133
 
134
+ # Generates a hash.
135
+ # Takes a required object and an optional view.
136
+ #
137
+ # @param object [Object] the Object to serialize upon.
138
+ # @param options [Hash] the options hash which requires a :view. Any
139
+ # additional key value pairs will be exposed during serialization.
140
+ # @option options [Symbol] :view Defaults to :default.
141
+ # The view name that corresponds to the group of
142
+ # fields to be serialized.
143
+ #
144
+ # @example Generating a hash with an extended view
145
+ # post = Post.all
146
+ # Blueprinter::Base.render_as_hash post, view: :extended
147
+ # # => [{id:1, title: Hello},{id:2, title: My Day}]
148
+ #
149
+ # @return [Hash]
150
+ def self.render_as_hash(object, options= {})
151
+ view_name = options.delete(:view) || :default
152
+ prepare(object, view_name: view_name, local_options: options)
153
+ end
154
+
134
155
  # This is the magic method that converts complex objects into a simple hash
135
156
  # ready for JSON conversion.
136
157
  #
@@ -1,3 +1,3 @@
1
1
  module Blueprinter
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blueprinter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hess
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-04-05 00:00:00.000000000 Z
12
+ date: 2018-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri