pragmatic_serializer 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f989efdf00a8f3a04142577c76d5190a430287dd
4
- data.tar.gz: e5eaca6087d796aab8a7edf1356edf151185c953
3
+ metadata.gz: 8459cbb6e538aea800ea54a28f6c0af9b077139e
4
+ data.tar.gz: 95149a2b02c694c1aa9facbdf03a84a3dcc51000
5
5
  SHA512:
6
- metadata.gz: 5e3221363a8f0aeea292f117efeae5fbd2c716a9f94cc9f521057565b56f1778dc8f876c55f47327393f4dab73f40cba74584a323a0ec9f90fbc656e449e0080
7
- data.tar.gz: 683b346ef7875cd0a0129101523a73f3d5961a86b2e6f834ff4812914a08f79f66186ca40d7f502e4fafa5531e482cb8907f8744a738b66e35105ba1d0dd0518
6
+ metadata.gz: ed6ba603de3183efe1b893df58225b76532d9d379550517ea789724cade12e46afd78a9786aaf6fb9579679dd72b598c39cce2f4c972747cb8d642b545f781da
7
+ data.tar.gz: f74a3dd99aace5e9f9dbd2110866916bc673d5923da7b93bbf49c487e683351f339dab17e88a75a548eb16948818bad45dbd9bfdd765a3be4c98d10fa5aa1f79
data/README.md CHANGED
@@ -23,7 +23,7 @@ Also the gem don't extend anything Rails wise (therefore Sinatra can use
23
23
  it too), it just provides a generic
24
24
  way to build Plain Ruby Object Serializers that you can call `as_json`
25
25
  on to produce hash that you can then pass to `render json:
26
- DocumentSerializer.new(document: Document.last).as_json`
26
+ DocumentSerializer.new(Document.last).as_json`
27
27
 
28
28
  ## Installation
29
29
 
@@ -33,11 +33,11 @@ module PragmaticSerializer
33
33
  end
34
34
 
35
35
  private
36
- def_delegators :resource_serializer, :resource_prefix, :collection_prefix
36
+ def_delegators :resource_serializer, :collection_prefix
37
37
 
38
38
  def collection_serializers
39
39
  resources.map do |resource|
40
- resource_object = resource_serializer.new(resource_prefix => resource)
40
+ resource_object = resource_serializer.new(resource)
41
41
 
42
42
  resource_options.each do |method_name, value|
43
43
  resource_object.send(method_name, value)
@@ -15,7 +15,7 @@ module PragmaticSerializer
15
15
  protected
16
16
 
17
17
  def json_id_value
18
- send(prefix).send(json_id_source) || raise(IDHasNoValue)
18
+ resource.send(json_id_source) || raise(IDHasNoValue)
19
19
  end
20
20
 
21
21
  def json_id_source
@@ -1,14 +1,11 @@
1
1
  module PragmaticSerializer
2
2
  module GeneralInitialization
3
3
  def self.included(base)
4
- base.send(:attr_reader, base.resource_prefix)
4
+ base.send(:attr_reader, :resource)
5
5
  end
6
6
 
7
- def initialize(**options)
8
- value = options.fetch(prefix) do |x|
9
- raise ArgumentError.new("missing keyword: #{x}")
10
- end
11
- instance_variable_set("@#{prefix}", value)
7
+ def initialize(resource)
8
+ @resource = resource
12
9
  end
13
10
  end
14
11
  end
@@ -1,3 +1,3 @@
1
1
  module PragmaticSerializer
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pragmatic_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Valent