simple_model 1.4.0 → 1.4.1
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/.travis.yml +0 -1
- data/benchmarks/simple_model.rb +12 -12
- data/lib/simple_model/attributes.rb +3 -1
- data/lib/simple_model/config.rb +1 -1
- data/lib/simple_model/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: 4ed17a81c487856f929ab1d5bc05a8c89414b93c
|
|
4
|
+
data.tar.gz: dc64ef73dfd207421014127616a13e4d55fc9e04
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 79b0a3d2342b150e50c5dc176da157469fde7196effe529fc04ad2759edebbb6ba427e5de318c266fafaf2651ed4cd5585a9be06f24e479f30ed2f3d1f9d39ae
|
|
7
|
+
data.tar.gz: 5cfca5c5954df4e38fde878ba77cadda5fcdc60108181faca997f10df5d9874c7392368df384caecdb3622c3b3ee99b7d657ca91144e5f62645a4f29ed858b94
|
data/.travis.yml
CHANGED
data/benchmarks/simple_model.rb
CHANGED
|
@@ -76,20 +76,20 @@ Benchmark.bmbm do |b|
|
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
-
# ruby 2.
|
|
79
|
+
# ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin13]
|
|
80
80
|
|
|
81
81
|
# Rehearsal ------------------------------------------------
|
|
82
|
-
# init 0.
|
|
83
|
-
# init w/attrs 1.
|
|
84
|
-
# get 0.
|
|
85
|
-
# get? 0.
|
|
86
|
-
# set
|
|
87
|
-
# --------------------------------------- total: 3.
|
|
82
|
+
# init 0.140000 0.000000 0.140000 ( 0.141798)
|
|
83
|
+
# init w/attrs 1.050000 0.000000 1.050000 ( 1.050091)
|
|
84
|
+
# get 0.440000 0.000000 0.440000 ( 0.449112)
|
|
85
|
+
# get? 0.560000 0.000000 0.560000 ( 0.551089)
|
|
86
|
+
# set 0.920000 0.000000 0.920000 ( 0.924776)
|
|
87
|
+
# --------------------------------------- total: 3.110000sec
|
|
88
88
|
|
|
89
89
|
# user system total real
|
|
90
|
-
# init 0.
|
|
91
|
-
# init w/attrs 1.
|
|
92
|
-
# get 0.
|
|
93
|
-
# get? 0.
|
|
94
|
-
# set
|
|
90
|
+
# init 0.130000 0.000000 0.130000 ( 0.127565)
|
|
91
|
+
# init w/attrs 1.050000 0.010000 1.060000 ( 1.050821)
|
|
92
|
+
# get 0.450000 0.000000 0.450000 ( 0.453590)
|
|
93
|
+
# get? 0.560000 0.000000 0.560000 ( 0.560942)
|
|
94
|
+
# set 0.950000 0.000000 0.950000 ( 0.949407)
|
|
95
95
|
|
|
@@ -40,7 +40,7 @@ module SimpleModel
|
|
|
40
40
|
attrs.stringify_keys!
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
|
-
@attributes = attrs
|
|
43
|
+
@attributes = attrs
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
# Returns true if attribute has been initialized
|
|
@@ -67,6 +67,7 @@ module SimpleModel
|
|
|
67
67
|
attr_key = to_attr_key(attr)
|
|
68
68
|
if allow_attribute_action?(val,opts)
|
|
69
69
|
ab = opts[:allow_blank]
|
|
70
|
+
|
|
70
71
|
val = fetch_default_value(opts[:default]) unless skip_set_default?(attr,opts,val,ab)
|
|
71
72
|
unless (opts[:boolean] ? (!ab && val.blank? && (val != false)) : (!ab && val.blank?))
|
|
72
73
|
val = process_on_set(opts[:on_set],val) if opts.has_key?(:on_set)
|
|
@@ -194,6 +195,7 @@ module SimpleModel
|
|
|
194
195
|
end
|
|
195
196
|
|
|
196
197
|
def allow_attribute_action?(val,options)
|
|
198
|
+
return false if !options[:boolean] && !options[:allow_blank] && val.blank?
|
|
197
199
|
return true unless (options.has_key?(:if) || options.has_key?(:unless))
|
|
198
200
|
b = true
|
|
199
201
|
opt = nil
|
data/lib/simple_model/config.rb
CHANGED
|
@@ -2,7 +2,7 @@ module SimpleModel
|
|
|
2
2
|
class Config
|
|
3
3
|
DEFAULTS = {
|
|
4
4
|
:initialize_defaults => false,
|
|
5
|
-
:attributes_store => :string # OPTIONS => :string, :symbol, :indifferent
|
|
5
|
+
:attributes_store => (RUBY_VERSION =~ /^2.2/ ? :symbol : :string) # OPTIONS => :string, :symbol, :indifferent
|
|
6
6
|
}.freeze
|
|
7
7
|
|
|
8
8
|
ATTRIBUTE_STORES = {
|
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.4.
|
|
4
|
+
version: 1.4.1
|
|
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: 2015-04
|
|
11
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
147
147
|
version: '0'
|
|
148
148
|
requirements: []
|
|
149
149
|
rubyforge_project: simple_model
|
|
150
|
-
rubygems_version: 2.4.
|
|
150
|
+
rubygems_version: 2.4.8
|
|
151
151
|
signing_key:
|
|
152
152
|
specification_version: 4
|
|
153
153
|
summary: Simpifies building tableless models or models backed by webservices
|