proxima 0.3.2 → 1.0.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: c71acef7a7a680c478bf0e074442f7eea364839f
4
- data.tar.gz: b32348b4e032e8d6fdb0c5bfa0aa28c3cacb62a8
3
+ metadata.gz: aa932b050d7417a30200065e08bd1f1b7c769107
4
+ data.tar.gz: e710e6b680d1996ba891a8ab8939084f3325e80d
5
5
  SHA512:
6
- metadata.gz: fba6e6552f8864f28ef2f1e37a8e3009a4fe326cd94eca4173554c6030e43f9bc0571ea54994bfdd5a690414a70b2ce81d42714dcc2b3fff20feaa098e75302b
7
- data.tar.gz: 4838de09244d31c6256a1a55eabe70984da12968e27c356638b5e810a45ecb040ee3966ead87da6b010b12d35578adff09342b29b8cf1c28351e54973333e64e
6
+ metadata.gz: c147cef8a8a9ad828c0a20062a354d43d8ebcaa243cdb24ad3ba5facd2cab7db258300b2ae6df8f741b8bfc825dfec5c6bedd23393b940701186128ea9d64349
7
+ data.tar.gz: 2515e810ee5260fad961ac819e9f666ce2e9458e46a5f507581952e8e81c40ed5e73583efc276bc95c7bf5f50d6f18131e17d788549bbdde9244833ba584dbd3
@@ -22,7 +22,7 @@ module Proxima
22
22
 
23
23
  if value != nil && attribute_params[:klass] && !value.is_a?(attribute_params[:klass])
24
24
  klass = attribute_params[:klass]
25
- value = klass.new value
25
+ value = Proxima::type_from_json klass, value
26
26
  end
27
27
 
28
28
  self.send "#{attribute}=", value
@@ -1,5 +1,5 @@
1
1
 
2
2
 
3
3
  module Proxima
4
- VERSION = "0.3.2"
4
+ VERSION = "1.0.0"
5
5
  end
data/lib/proxima.rb CHANGED
@@ -5,7 +5,7 @@ require "proxima/model"
5
5
 
6
6
  module Proxima
7
7
 
8
- TYPES = [
8
+ @types = [
9
9
  {
10
10
  klass: String,
11
11
  from_json: -> v { v.to_s },
@@ -46,7 +46,7 @@ module Proxima
46
46
  ]
47
47
 
48
48
  def self.add_type(klass, from = nil, to = nil)
49
- TYPES.push({
49
+ @types.push({
50
50
  klass: klass,
51
51
  from: from,
52
52
  to: to
@@ -54,7 +54,7 @@ module Proxima
54
54
  end
55
55
 
56
56
  def self.remove_type(klass)
57
- TYPES.delete_if({
57
+ @types.delete_if({
58
58
  klass: klass,
59
59
  from: from,
60
60
  to: to
@@ -62,12 +62,12 @@ module Proxima
62
62
  end
63
63
 
64
64
  def self.type_from_json(klass, value)
65
- type = TYPES.find { |t| t[:klass] == klass }
66
- type.from_json(value) if type else value
65
+ type = @types.find { |t| t[:klass] == klass }
66
+ type[:from_json].call(value) if type else value
67
67
  end
68
68
 
69
69
  def self.type_to_json(klass, value)
70
- type = TYPES.find { |t| t[:klass] == klass }
71
- type.to_json(value) if type else value
70
+ type = @types.find { |t| t[:klass] == klass }
71
+ type[:to_json].call(value) if type else value
72
72
  end
73
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxima
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Hurst
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-16 00:00:00.000000000 Z
11
+ date: 2017-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler