seri 0.1.0 → 0.1.1

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: 235047fde67dba9419cb66b80ae8bf6ab57f167dd56221b6deaace66967d2997
4
- data.tar.gz: a2a7b26b30531f9633feec79dde2ae10f64aad7eb49926078d0b925fb5d28a61
3
+ metadata.gz: 0cd689240bcf4de7c1e6e8e583a1a465c1d61102cb8d5aa26e99c50ddbe84399
4
+ data.tar.gz: 69f82fa0bae7cd349713bf98f44454acb0fdd217491cf8cae9d07d0f1c4cceaf
5
5
  SHA512:
6
- metadata.gz: 0d86a1667787e7e807d87675196b254bfd686e18da9e9cba6636c0a6c6345771295edab70645456c70e80418c184dc0570ab2095c8cb57d52b3af91e4b13a367
7
- data.tar.gz: d9e9fb1aed4e27f70674e6795035b36428f5a6ab5ac15341fff02a883a0db25a8a584ee6243f192d913cd1b3515f867761361a44bf20a39e0579c703c0fd8ab8
6
+ metadata.gz: '010940cfb05b32b29af2ed9df5539832003cc829de76b9878844474f822d8499a47a16cb4798a74ec4f34a4455d3126c61cc66ac7b958f882489d4432da64287'
7
+ data.tar.gz: 7d1311e5bc7712923a4acc852d95e3525ce63a28cb9319c3e792e64c2132bb00870045705b2702f32dbff1747e05d2eccccbf600a605aaf7c9f54b8384e08a2b
data/.circleci/config.yml CHANGED
@@ -1,18 +1,10 @@
1
1
  # Ruby CircleCI 2.0 configuration file
2
- #
3
- # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
- #
5
2
  version: 2
6
3
  jobs:
7
4
  build:
8
5
  docker:
9
6
  # specify the version you desire here
10
- - image: circleci/ruby:2.4.1-node-browsers
11
-
12
- # Specify service dependencies here if necessary
13
- # CircleCI maintains a library of pre-built images
14
- # documented at https://circleci.com/docs/2.0/circleci-images/
15
- # - image: circleci/postgres:9.4
7
+ - image: circleci/ruby:2.5.3-node-browsers
16
8
 
17
9
  working_directory: ~/repo
18
10
 
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- serializer (0.1.0)
4
+ seri (0.1.0)
5
5
  appsignal (~> 2.7)
6
6
  oj (~> 3.7)
7
7
 
@@ -35,7 +35,7 @@ DEPENDENCIES
35
35
  bundler (~> 1.16)
36
36
  rake (~> 10.0)
37
37
  rspec (~> 3.0)
38
- serializer!
38
+ seri!
39
39
 
40
40
  BUNDLED WITH
41
41
  1.16.2
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Seri
2
2
 
3
- [![CircleCI](https://circleci.com/gh/grdw/serializer.svg?style=svg)](https://circleci.com/gh/grdw/serializer)
3
+ [![CircleCI](https://circleci.com/gh/grdw/seri.svg?style=svg)](https://circleci.com/gh/grdw/seri)
4
4
 
5
5
  A basic replacement for gems like `active_model_serializers`. Can turn any
6
6
  basic Ruby object into a Hash or JSON string with features like:
@@ -1,3 +1,3 @@
1
1
  class Serializer
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/serializer.rb CHANGED
@@ -36,13 +36,13 @@ class Serializer
36
36
  value = if attribute.options.has_key?(:static_value)
37
37
  attribute.options.fetch(:static_value)
38
38
  elsif respond_to?(extraction_key)
39
- public_send(extraction_key)
40
- elsif object.respond_to?(extraction_key) && attribute.serializer
41
- value = object.public_send(extraction_key)
39
+ value = public_send(extraction_key)
42
40
 
43
41
  serialize_value(value, attribute.serializer)
44
42
  elsif object.respond_to?(extraction_key)
45
- object.public_send(extraction_key)
43
+ value = object.public_send(extraction_key)
44
+
45
+ serialize_value(value, attribute.serializer)
46
46
  else
47
47
  raise SerializerError, "unknown attribute '#{extraction_key}'"
48
48
  end
@@ -60,6 +60,8 @@ class Serializer
60
60
  private
61
61
 
62
62
  def serialize_value(value, serializer)
63
+ return value unless serializer
64
+
63
65
  if value.is_a?(Array)
64
66
  value.map { |v| serializer.new(v).to_h }
65
67
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - grdw
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-30 00:00:00.000000000 Z
11
+ date: 2018-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj