mholling-active_url 0.1.2 → 0.1.3
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.
- data/Rakefile +1 -0
- data/VERSION.yml +1 -1
- data/lib/active_url/base.rb +3 -7
- data/lib/active_url/crypto.rb +2 -0
- data/spec/belongs_to_spec.rb +1 -1
- data/spec/instance_spec.rb +12 -2
- data/spec/validations_spec.rb +2 -2
- metadata +2 -2
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
data/lib/active_url/base.rb
CHANGED
|
@@ -9,11 +9,6 @@ module ActiveUrl
|
|
|
9
9
|
def self.attribute(*attribute_names)
|
|
10
10
|
options = attribute_names.extract_options!
|
|
11
11
|
attribute_names.map(&:to_sym).each { |attribute_name| add_attribute(attribute_name, options) }
|
|
12
|
-
# attribute_names.map(&:to_sym).each do |attribute_name|
|
|
13
|
-
# attr_accessor attribute_name
|
|
14
|
-
# self.attribute_names << attribute_name
|
|
15
|
-
# self.accessible_attributes << attribute_name if options[:accessible]
|
|
16
|
-
# end
|
|
17
12
|
end
|
|
18
13
|
|
|
19
14
|
def self.attr_accessible(*attribute_names)
|
|
@@ -60,7 +55,7 @@ module ActiveUrl
|
|
|
60
55
|
raise RecordNotFound unless id.is_a?(String) && !id.blank?
|
|
61
56
|
serialized = begin
|
|
62
57
|
Crypto.decrypt(id)
|
|
63
|
-
rescue
|
|
58
|
+
rescue Crypto::CipherError
|
|
64
59
|
raise RecordNotFound
|
|
65
60
|
end
|
|
66
61
|
type, attributes = YAML.load(serialized)
|
|
@@ -93,9 +88,10 @@ module ActiveUrl
|
|
|
93
88
|
self.accessible_attributes = Set.new
|
|
94
89
|
|
|
95
90
|
def self.add_attribute(attribute_name, options)
|
|
96
|
-
attr_accessor attribute_name
|
|
97
91
|
self.attribute_names << attribute_name
|
|
98
92
|
self.accessible_attributes << attribute_name if options[:accessible]
|
|
93
|
+
public
|
|
94
|
+
attr_accessor attribute_name
|
|
99
95
|
end
|
|
100
96
|
end
|
|
101
97
|
|
data/lib/active_url/crypto.rb
CHANGED
data/spec/belongs_to_spec.rb
CHANGED
data/spec/instance_spec.rb
CHANGED
|
@@ -39,7 +39,7 @@ describe ActiveUrl do
|
|
|
39
39
|
|
|
40
40
|
context "derived" do
|
|
41
41
|
before(:all) do
|
|
42
|
-
class DerivedClass < ActiveUrl::Base
|
|
42
|
+
class ::DerivedClass < ActiveUrl::Base
|
|
43
43
|
attribute :foo, :bar
|
|
44
44
|
attribute :baz, :accessible => true
|
|
45
45
|
attr_accessible :bar
|
|
@@ -50,6 +50,16 @@ describe ActiveUrl do
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
context "instance" do
|
|
53
|
+
it "should have individually accessible attribute readers" do
|
|
54
|
+
@url = DerivedClass.new
|
|
55
|
+
[ :foo, :bar, :baz ].each { |reader| @url.public_methods.map(&:to_sym).should include(reader) }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should have individually accessible attribute setters" do
|
|
59
|
+
@url = DerivedClass.new
|
|
60
|
+
[ :foo=, :bar=, :baz= ].each { |setter| @url.public_methods.map(&:to_sym).should include(setter) }
|
|
61
|
+
end
|
|
62
|
+
|
|
53
63
|
it "should not mass-assign attributes by default" do
|
|
54
64
|
@url = DerivedClass.new(:foo => "foo")
|
|
55
65
|
@url.foo.should be_nil
|
|
@@ -89,7 +99,7 @@ describe ActiveUrl do
|
|
|
89
99
|
|
|
90
100
|
context "equality" do
|
|
91
101
|
before(:all) do
|
|
92
|
-
class OtherClass < DerivedClass
|
|
102
|
+
class ::OtherClass < DerivedClass
|
|
93
103
|
end
|
|
94
104
|
end
|
|
95
105
|
|
data/spec/validations_spec.rb
CHANGED
|
@@ -7,7 +7,7 @@ describe ActiveUrl do
|
|
|
7
7
|
|
|
8
8
|
context "instance with validations" do
|
|
9
9
|
before(:all) do
|
|
10
|
-
class Registration < ActiveUrl::Base
|
|
10
|
+
class ::Registration < ActiveUrl::Base
|
|
11
11
|
attribute :name, :email, :password, :age, :accessible => true
|
|
12
12
|
validates_presence_of :name
|
|
13
13
|
validates_format_of :email, :with => /^[\w\.=-]+@[\w\.-]+\.[a-zA-Z]{2,4}$/ix
|
|
@@ -93,7 +93,7 @@ describe ActiveUrl do
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
it "should execute any after_save callbacks" do
|
|
96
|
-
@registration.instance_variables.should include("@sent")
|
|
96
|
+
@registration.instance_variables.map(&:to_s).should include("@sent")
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
context "and re-found by its class" do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mholling-active_url
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matthew Hollingworth
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-06-09 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|