simple_model 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a8ba23df5889853f9ad2166692f109b20091bfc
4
- data.tar.gz: a8aee80ab3a098d528ba4b8028267edd4e34de5f
3
+ metadata.gz: 4ed17a81c487856f929ab1d5bc05a8c89414b93c
4
+ data.tar.gz: dc64ef73dfd207421014127616a13e4d55fc9e04
5
5
  SHA512:
6
- metadata.gz: a8968daba7cc06a8be4d3b98670fd15d9c857dfdc18dc16fedc2c3a6fe7c6f3ce1fdcc6f7e0e0fe9eb85ff64b47253c65c753bf2c05ffeca3e9060e261f6e07d
7
- data.tar.gz: 83f31f449c53ea75bac4f14ba57a827c72130ae2eebd36675e6f9e84fa2bba6d8b13874aca613ae6283167411e357591c04fed95187d9e74c75b768cb48245d4
6
+ metadata.gz: 79b0a3d2342b150e50c5dc176da157469fde7196effe529fc04ad2759edebbb6ba427e5de318c266fafaf2651ed4cd5585a9be06f24e479f30ed2f3d1f9d39ae
7
+ data.tar.gz: 5cfca5c5954df4e38fde878ba77cadda5fcdc60108181faca997f10df5d9874c7392368df384caecdb3622c3b3ee99b7d657ca91144e5f62645a4f29ed858b94
data/.travis.yml CHANGED
@@ -4,7 +4,6 @@ rvm:
4
4
  - 2.2
5
5
  - 2.1
6
6
  - 2.0.0
7
- - 1.9.3
8
7
  - jruby
9
8
  script: bundle exec rspec spec
10
9
  gemfile:
@@ -76,20 +76,20 @@ Benchmark.bmbm do |b|
76
76
  end
77
77
  end
78
78
 
79
- # ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
79
+ # ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin13]
80
80
 
81
81
  # Rehearsal ------------------------------------------------
82
- # init 0.150000 0.000000 0.150000 ( 0.149609)
83
- # init w/attrs 1.100000 0.000000 1.100000 ( 1.101177)
84
- # get 0.490000 0.000000 0.490000 ( 0.491134)
85
- # get? 0.600000 0.000000 0.600000 ( 0.598875)
86
- # set 1.170000 0.000000 1.170000 ( 1.171242)
87
- # --------------------------------------- total: 3.510000sec
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.140000 0.000000 0.140000 ( 0.140109)
91
- # init w/attrs 1.060000 0.000000 1.060000 ( 1.055176)
92
- # get 0.490000 0.000000 0.490000 ( 0.491473)
93
- # get? 0.600000 0.000000 0.600000 ( 0.600557)
94
- # set 1.200000 0.010000 1.210000 ( 1.196884)
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
@@ -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 = {
@@ -1,3 +1,3 @@
1
1
  module SimpleModel
2
- VERSION = "1.4.0"
2
+ VERSION = "1.4.1"
3
3
  end
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.0
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-14 00:00:00.000000000 Z
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.6
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