valuable 0.9.12 → 0.9.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/valuable/utils.rb +9 -0
- data/test/bad_attributes_test.rb +8 -0
- data/test/custom_initializer_test.rb +1 -1
- data/test/deprecated_test.rb +1 -1
- data/test/inheritance_test.rb +1 -1
- data/test/parse_with_test.rb +1 -1
- data/test/valuable_test.rb +1 -1
- data/valuable.version +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: da8784960fceb040aaabcb25475c849731245869
|
4
|
+
data.tar.gz: 184e99edcf813a8bc0870d96588d0ac131d26698
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79ea215a33a5510fe1a323e12a5599bd1399059fb1a87bfd05eb606fce7c113b1426301f41803eaeef876b52f7b4a230954ba567cbc3a186927f08a30def7104
|
7
|
+
data.tar.gz: f4aa9ca89a97ed94363a9e6c29022ea8ea32fd8d3d631a2cc28dc1473a353486cd0906d4297678edef0da974b59564e0fc2bcc6f18f446afe958e8cefea88838
|
data/Gemfile.lock
CHANGED
data/lib/valuable/utils.rb
CHANGED
@@ -118,12 +118,21 @@ module Valuable::Utils
|
|
118
118
|
[:klass, :default, :negative, :alias, :parse_with, :extend, :allow_blank]
|
119
119
|
end
|
120
120
|
|
121
|
+
def can_be_duplicated?( item )
|
122
|
+
Marshal.dump(item)
|
123
|
+
true
|
124
|
+
rescue
|
125
|
+
false
|
126
|
+
end
|
127
|
+
|
121
128
|
# this helper raises an exception if the options passed to has_value
|
122
129
|
# are wrong. Mostly written because I occasionally used :class instead
|
123
130
|
# of :klass and, being a moron, wasted time trying to find the issue.
|
124
131
|
def check_options_validity( class_name, attribute, options )
|
125
132
|
invalid_options = options.keys - known_options
|
126
133
|
|
134
|
+
raise ArgumentError, "#{class_name}##{attribute} has a default value that must be set using a lambda. Use :default => lambda { Thing.new }." if options[:default] && !options[:default].kind_of?(Proc) && !can_be_duplicated?( options[:default] )
|
135
|
+
|
127
136
|
raise ArgumentError, "has_value did not know how to respond to option(s) #{invalid_options.join(', ')}. Valid (optional) arguments are: #{known_options.join(', ')}" unless invalid_options.empty?
|
128
137
|
|
129
138
|
raise ArgumentError, "#{class_name} doesn't know how to format #{attribute} with :klass => #{options[:klass].inspect}" unless klass_options.any?{|klass| klass === options[:klass]}
|
data/test/bad_attributes_test.rb
CHANGED
@@ -35,5 +35,13 @@ class BadAttributesTest < Test::Unit::TestCase
|
|
35
35
|
model.new(:invalid => 'should be ignored')
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
def test_that_we_provide_a_better_error_when_objects_can_not_be_marhsaled
|
40
|
+
assert_raises ArgumentError do
|
41
|
+
Class.new(Valuable) do
|
42
|
+
has_value :invalid, :default => StringIO.new
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
38
46
|
end
|
39
47
|
|
data/test/deprecated_test.rb
CHANGED
data/test/inheritance_test.rb
CHANGED
data/test/parse_with_test.rb
CHANGED
data/test/valuable_test.rb
CHANGED
data/valuable.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.13
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valuable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johnathon Wright
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Valuable is a ruby base class that is essentially attr_accessor on steroids.
|
14
14
|
A simple and intuitive interface allows you to get on with modeling in your app.
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
requirements: []
|
68
68
|
rubyforge_project:
|
69
|
-
rubygems_version: 2.
|
69
|
+
rubygems_version: 2.5.1
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: attr_accessor on steroids with defaults, attribute formatting, alias methods,
|