attr_symbol 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/attr_symbol.gemspec +1 -1
- data/lib/attr_symbol.rb +0 -4
- data/test/test_attr_symbol.rb +0 -22
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/attr_symbol.gemspec
CHANGED
data/lib/attr_symbol.rb
CHANGED
@@ -8,10 +8,6 @@ module ActiveRecord::AttrSymbol
|
|
8
8
|
|
9
9
|
def attr_symbol(*attributes)
|
10
10
|
attributes.each do |attr|
|
11
|
-
unless columns_hash[attr.to_s] && columns_hash[attr.to_s].type == :string
|
12
|
-
raise ArgumentError, "Attribute :#{attr} is not a database column of type string"
|
13
|
-
end
|
14
|
-
|
15
11
|
define_method(attr) do
|
16
12
|
self[attr].try(:to_sym)
|
17
13
|
end
|
data/test/test_attr_symbol.rb
CHANGED
@@ -62,26 +62,4 @@ class TestAttrSymbol < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
66
|
-
context "Calling #attr_symbol with a column that does not exist" do
|
67
|
-
should "raise ArgumentError" do
|
68
|
-
begin
|
69
|
-
Thing.send(:attr_symbol, :missing_attr)
|
70
|
-
fail "Expected ArgumentError but no exception thrown"
|
71
|
-
rescue ArgumentError => e
|
72
|
-
assert_equal "Attribute :missing_attr is not a database column of type string", e.message
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context "Calling #attr_symbol with a column that is not a string" do
|
78
|
-
should "raise ArgumentError" do
|
79
|
-
begin
|
80
|
-
Thing.send(:attr_symbol, :bar)
|
81
|
-
fail "Expected ArgumentError but no exception thrown"
|
82
|
-
rescue ArgumentError => e
|
83
|
-
assert_equal "Attribute :bar is not a database column of type string", e.message
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
65
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attr_symbol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Wienckowski
|