red_cap 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/red_cap/form/fields.rb +6 -2
- data/lib/red_cap/form.rb +5 -3
- data/lib/red_cap/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17f8b084c1543f1c9ebda525009e0b117e4376ca
|
4
|
+
data.tar.gz: 861b0f0b47d80da062846a58a0216c3d365b68b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6958e11b0de0d79a1770fcddc68a5639338fc4f933b973643d57160468bd6f1c07a7870eaae68d91fd2d03629c70a627083158bd5aa38b9cc190bd248418a3a8
|
7
|
+
data.tar.gz: f19581696f6463a2daf2ccbaaf9993ea3d694999f5f20768df5724e0577c937a3a181fd65864458135ea838a6b47e236d5fc7fef4f4b1664784ff54e2e75532d
|
data/lib/red_cap/form/fields.rb
CHANGED
@@ -2,7 +2,7 @@ require "active_support/core_ext/object/blank"
|
|
2
2
|
|
3
3
|
module REDCap
|
4
4
|
class Form
|
5
|
-
class Field < Struct.new(:form, :attributes, :responses)
|
5
|
+
class Field < Struct.new(:form, :attributes, :responses, :options)
|
6
6
|
KEYS = [
|
7
7
|
:field_name,
|
8
8
|
:form_name,
|
@@ -66,7 +66,11 @@ module REDCap
|
|
66
66
|
|
67
67
|
class Yesno < Field
|
68
68
|
def value
|
69
|
-
super == "
|
69
|
+
if options.has_key?(:default) && super == ""
|
70
|
+
options[:default]
|
71
|
+
else
|
72
|
+
super == "1"
|
73
|
+
end
|
70
74
|
end
|
71
75
|
end
|
72
76
|
|
data/lib/red_cap/form.rb
CHANGED
@@ -13,20 +13,22 @@ module REDCap
|
|
13
13
|
# field accessors
|
14
14
|
def method_missing method, *args, **kwargs, &block
|
15
15
|
key = method.to_s
|
16
|
-
|
16
|
+
options = kwargs.dup
|
17
|
+
field_class = options.delete(:as)
|
17
18
|
if field_class.is_a?(Symbol)
|
18
19
|
field_class = lookup_field_class(field_class.to_s)
|
19
20
|
end
|
20
|
-
if field = find_field(key, field_class)
|
21
|
+
if field = find_field(key, field_class, options)
|
21
22
|
field.value
|
22
23
|
else
|
23
24
|
super
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
|
-
def find_field key, field_class
|
28
|
+
def find_field key, field_class, options
|
28
29
|
field = fields.find { |field| field.field_name == key }
|
29
30
|
field = field_class.new(self, field.attributes, responses) if field_class
|
31
|
+
field.options = options
|
30
32
|
field
|
31
33
|
end
|
32
34
|
|
data/lib/red_cap/version.rb
CHANGED