cerulean 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cerulean.rb +8 -30
  3. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a55c2f55e2a8e0b5706ecc63c45195b3694ebe3
4
- data.tar.gz: caeff050b3016337f6e3d27c25815f2a53f7eecb
3
+ metadata.gz: 613d12d6dfd8bcf13d8cfbb2780fac908e91cc35
4
+ data.tar.gz: 5675ffac3951f9496a381ad2fb9faa2a9bd844a1
5
5
  SHA512:
6
- metadata.gz: cffe40593fc289fefc08e3ae36afd19c11d52eb171a40478e263285e6c9ce4b21c9750babf297ba9bb39f1219d1fd7152a34b85cc7f1db65fb1b7b33b984d2e6
7
- data.tar.gz: 11d1b53ea9435d18df564290b3639694ddf4c92817f7db332ffa1949828ccb6cc86472048725b07fbb9bbdfeda7de5eb4ec633f0b617ad5e7db189405a6b6253
6
+ metadata.gz: 39cd304299549ebe005c140f5828515d67db5fd4080c80ba328babf1d41d632d8002032f59ba7d258be6add6f6b492aeff8818a51a9656cac0c6f83fc00d829f
7
+ data.tar.gz: cd3e5668bc99ba6ea6dc33c1854d5e3bc01d998b6b08fc7c183b13003084c3f1bc0bdca74cc660018cce1b711874a7ad46b523fdeae5d4d309051d86d824cc30
data/lib/cerulean.rb CHANGED
@@ -1,4 +1,4 @@
1
- module Boolean; end
1
+ require 'boolean'
2
2
 
3
3
  class ActionDSL
4
4
  def initialize(controller, name:, &block)
@@ -56,6 +56,8 @@ module Cerulean
56
56
  ActionDSL.new(self, name: name, &block)
57
57
 
58
58
  self.class_exec do
59
+ require 'boolean'
60
+
59
61
  def declared()
60
62
  @declared ||= {} #Hashie::Mash.new(params)
61
63
  end
@@ -80,39 +82,15 @@ module Cerulean
80
82
  @meta ||= self.class.class_variable_get(:@@meta)[action_name.to_sym]
81
83
  end
82
84
 
83
- def parse_integer(val)
84
- Integer(val) rescue nil
85
- end
86
-
87
- def parse_float(val)
88
- Float(val) rescue nil
89
- end
90
-
91
- def parse_boolean(val)
92
- case val.to_s.downcase
93
- when 'true'
94
- true
95
- when 'false'
96
- false
97
- else
98
- nil
99
- end
100
- end
101
-
102
85
  def validate_param_type(val, type)
103
86
  if val.is_a?(Array)
104
- parsed = val.map { |el| validate_param_type(el, type[0].to_s) }
105
- parsed.all? ? parsed : nil
87
+ parsed = val.map { |el| validate_param_type(el, type[0]) }
88
+ parsed.all? { |el| !el.nil? } ? parsed : nil
106
89
  else
107
- case type.to_s
108
- when 'Integer'
109
- parse_integer(val)
110
- when 'Float'
111
- parse_float(val)
112
- when 'Boolean'
113
- parse_boolean(val)
114
- when 'String'
90
+ if type == String
115
91
  val
92
+ else
93
+ Kernel.send(type.to_s, val) rescue nil
116
94
  end
117
95
  end
118
96
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cerulean
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Kestell
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-07-27 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: boolean
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: REST API DSL.
14
28
  email: kyle@kestell.org
15
29
  executables: []