simple_model 1.2.24 → 1.2.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/benchmarks/simple_model.rb +1 -1
- data/gemfiles/4.2.gemfile +2 -2
- data/lib/simple_model/attributes.rb +5 -5
- data/lib/simple_model/extend_core.rb +5 -5
- data/lib/simple_model/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDRhM2I3NjM1YThmYzJkOTU5YzNlMTVkNjVmMDE3Y2E4OGRmOTMzOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmRjNDE4M2MyZTI2M2VmZDQwNTczNmFjMjc5MGFiYmY2NmViYTc2MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjNmMDVjYzIzYTcxMzUwYzFlZjcwNzgxYzgyZjU0NTg1ODk5NTZhYWM5OTJk
|
10
|
+
NmE5ZGU1ZDAxZDBhMmNjZDU1NmE3YzcwMzRiZWM3OGFjMGVjMTY3YTQwM2M1
|
11
|
+
ZDc1ZjI4ZDAwMGZmYWM3NWJmNmQwODZlZDc0ODBiNDFhYTEwN2E=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDM4NTljY2IzOTRlNmVjMmZkNTM1NzJjNmI0NzA2Njc0OWVmMDBmMjlmMTk3
|
14
|
+
YTczZTJjOGQ2ODQ0OTMxMWEwOTc5MzAyM2JkMjYxNDFlZWQ1MzY0Mjk3OTBh
|
15
|
+
NTU2ZmU3NDlmMWJjYjRiNWM4MmIyZDJiZDYwNDY0ZDUxZjljZDU=
|
data/benchmarks/simple_model.rb
CHANGED
data/gemfiles/4.2.gemfile
CHANGED
@@ -61,13 +61,13 @@ module SimpleModel
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def get_attribute?(attr)
|
64
|
-
val = get_attribute(attr)
|
64
|
+
return false unless val = get_attribute(attr)
|
65
65
|
if val.respond_to?(:blank?)
|
66
66
|
return !val.blank?
|
67
67
|
elsif val.respond_to?(:to_b)
|
68
68
|
return val.to_b
|
69
69
|
end
|
70
|
-
val
|
70
|
+
!val.nil?
|
71
71
|
end
|
72
72
|
|
73
73
|
private
|
@@ -247,7 +247,7 @@ module SimpleModel
|
|
247
247
|
define_method(attr) do
|
248
248
|
get_attribute(attr)
|
249
249
|
end
|
250
|
-
define_method("#{attr
|
250
|
+
define_method("#{attr}?") do
|
251
251
|
get_attribute?(attr)
|
252
252
|
end
|
253
253
|
end
|
@@ -256,7 +256,7 @@ module SimpleModel
|
|
256
256
|
# On set, it will mark the attribute as changed if the attributes has been
|
257
257
|
# initialized.
|
258
258
|
def define_setter_with_options(attr,options)
|
259
|
-
define_method("#{attr
|
259
|
+
define_method("#{attr}=") do |val|
|
260
260
|
set_attribute(attr,val)
|
261
261
|
end
|
262
262
|
end
|
@@ -280,7 +280,7 @@ module SimpleModel
|
|
280
280
|
define_method("#{new_alias}?") do
|
281
281
|
send("#{attr}?")
|
282
282
|
end
|
283
|
-
define_method("#{new_alias
|
283
|
+
define_method("#{new_alias}=") do |*args, &block|
|
284
284
|
send("#{attr}=",*args, &block)
|
285
285
|
end
|
286
286
|
end
|
@@ -74,7 +74,7 @@ module SimpleModel
|
|
74
74
|
# * safe_date_string("\/Date(1310669017000)\/") # =>
|
75
75
|
def safe_datetime_string
|
76
76
|
safe_date = nil
|
77
|
-
if self[0..9]
|
77
|
+
if self[0..9] =~ (/^(0[1-9]|[1-9]|1[012])[- \/.]([1-9]|0[1-9]|[12][0-9]|3[01])[- \/.][0-9][0-9][0-9][0-9]/)
|
78
78
|
safe_date = ""
|
79
79
|
splt = split(/\-|\/|\./)
|
80
80
|
time = ""
|
@@ -86,8 +86,8 @@ module SimpleModel
|
|
86
86
|
safe_date << "#{splt[2]}-#{splt[0]}-#{splt[1]}"
|
87
87
|
safe_date << "#{time}" unless time.nil? || time.to_s.length == 0
|
88
88
|
end
|
89
|
-
elsif self
|
90
|
-
safe_date = Time.at(((self.gsub(/(\/Date\()/,"")).gsub(/\)\/$/,"").
|
89
|
+
elsif self =~ /^\/Date\(/
|
90
|
+
safe_date = Time.at(((self.gsub(/(\/Date\()/,"")).gsub(/\)\/$/,"").to_i) / 1000).to_s
|
91
91
|
else
|
92
92
|
safe_date = self
|
93
93
|
end
|
@@ -97,14 +97,14 @@ module SimpleModel
|
|
97
97
|
# Use safe_datetime_string help with those pesky US date formats in Ruby 1.9
|
98
98
|
# or to change an integer string to date
|
99
99
|
def to_date
|
100
|
-
return safe_datetime_string.to_i.to_date if self
|
100
|
+
return safe_datetime_string.to_i.to_date if self =~ /^+d$/
|
101
101
|
Date.parse(safe_datetime_string)
|
102
102
|
end
|
103
103
|
|
104
104
|
# Use safe_datetime_string help with those pesky US date formats in Ruby 1.9
|
105
105
|
# or to change an integer string to date
|
106
106
|
def to_time
|
107
|
-
return safe_datetime_string.to_i.to_time if self
|
107
|
+
return safe_datetime_string.to_i.to_time if self =~ /^+d$/
|
108
108
|
Time.parse(safe_datetime_string)
|
109
109
|
end
|
110
110
|
|
data/lib/simple_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua T Mckinney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|