contents_core 0.2.4 → 0.2.5
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 +4 -4
- data/app/models/contents_core/item.rb +19 -16
- data/app/models/contents_core/item_array.rb +6 -2
- data/lib/contents_core/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75a1c3e706d549e2a1760b2986ab6ed1c947e62c
|
4
|
+
data.tar.gz: 50c1f08869d686fb75509b3d26a92c8b59873196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ac52395df24233ceda982dceab0871716058adf72bfd99cb5fbb98b67ce519b7830186c37b68441a7542b7a11658a0127c9ea5f7084a4bf0875228a4fafe9e2
|
7
|
+
data.tar.gz: 92ccd52237adcb6bf89352b9d6d583984daac7c54aadb3659268efdca2dfe298eff598c24a0e6ca0545afa9f0286e75dbae82e6817fdf1a25fe63caa63bdd9fb
|
@@ -58,49 +58,52 @@ module ContentsCore
|
|
58
58
|
[ :data_boolean, :data_datetime, :data_file, :data_float, :data_hash, :data_integer, :data_string, :data_text ]
|
59
59
|
end
|
60
60
|
|
61
|
-
protected
|
62
|
-
|
63
61
|
def config
|
64
62
|
@config ||= self.block && self.block.config[:options] && self.block.config[:options][self.name.to_sym] ? self.block.config[:options][self.name.to_sym] : ( ContentsCore.config[:items][self.class::type_name.to_sym] ? ContentsCore.config[:items][self.class::type_name.to_sym] : {} )
|
65
63
|
end
|
66
64
|
|
65
|
+
def data_type
|
66
|
+
@data_type ||= ( config[:data_type] || :string ).to_sym
|
67
|
+
end
|
68
|
+
|
69
|
+
protected
|
70
|
+
|
67
71
|
def convert_data( value )
|
68
72
|
# return ( data = config[:convert_method].call( data ) ) if config[:convert_method]
|
69
|
-
if
|
70
|
-
case
|
73
|
+
if data_type
|
74
|
+
case data_type
|
71
75
|
when :boolean
|
72
76
|
self.data_boolean = ( value == 1 ) || ( value == '1' ) || ( value == 'true' ) || ( value == 'yes' )
|
73
77
|
when :float
|
74
78
|
self.data_float = value.to_f
|
75
79
|
when :integer
|
76
80
|
self.data_integer = value.to_i
|
77
|
-
when :string
|
78
|
-
self.data_string = value.to_s
|
79
81
|
when :text
|
80
82
|
self.data_text = value.to_s
|
81
|
-
else
|
82
|
-
|
83
|
+
else # :string or other
|
84
|
+
self.data_string = value.to_s
|
83
85
|
end
|
84
|
-
|
85
|
-
|
86
|
-
false
|
86
|
+
else # :string or other
|
87
|
+
self.data_string = value.to_s
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
90
|
-
def converted_data
|
91
|
-
if
|
92
|
-
case
|
91
|
+
def converted_data()
|
92
|
+
if data_type
|
93
|
+
case data_type
|
93
94
|
when :boolean
|
94
95
|
self.data_boolean
|
95
96
|
when :float
|
96
97
|
self.data_float
|
97
98
|
when :integer
|
98
99
|
self.data_integer
|
99
|
-
when :string
|
100
|
-
self.data_string
|
101
100
|
when :text
|
102
101
|
self.data_text
|
102
|
+
else # :string or other
|
103
|
+
self.data_string
|
103
104
|
end
|
105
|
+
else # :string or other
|
106
|
+
self.data_string
|
104
107
|
end
|
105
108
|
end
|
106
109
|
end
|
@@ -13,8 +13,8 @@ module ContentsCore
|
|
13
13
|
|
14
14
|
def data=( value )
|
15
15
|
if is_multiple?
|
16
|
-
if
|
17
|
-
self.data_text = case
|
16
|
+
if data_type
|
17
|
+
self.data_text = case data_type
|
18
18
|
# when :boolean
|
19
19
|
# self.data_boolean = ( value == 1 ) || ( value == '1' ) || ( value == 'true' ) || ( value == 'yes' )
|
20
20
|
when :float
|
@@ -34,6 +34,10 @@ module ContentsCore
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def data_type
|
38
|
+
@data_type ||= ( config[:data_type] || :integer ).to_sym
|
39
|
+
end
|
40
|
+
|
37
41
|
def enum( params = nil )
|
38
42
|
config[:values] ? config[:values] : ( config[:values_method] ? config[:values_method].call( params ) : self.data_hash )
|
39
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contents_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.6.
|
118
|
+
rubygems_version: 2.6.11
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Flexible contents structure for Rails
|