Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for attr_protected.

Closes #2.
  • Loading branch information...
commit ede5e1e4b70cec4af407d086b2114c01a7017f8d 1 parent bd323b7
@cpence authored
View
1  lib/yard-rails/attr_accessible_handler.rb
@@ -3,6 +3,7 @@ module YARD
module Rails
class AttrAccessibleHandler < YARD::Handlers::Ruby::AttributeHandler
handles method_call(:attr_accessible)
+ handles method_call(:attr_protected)
namespace_only
def process
View
2  lib/yard-rails/legacy/attr_accessible_handler.rb
@@ -3,7 +3,7 @@ module YARD
module Rails
module Legacy
class AttrAccessibleHandler < YARD::Handlers::Ruby::Legacy::AttributeHandler
- handles /\Aattr_accessible(?:\s|\()/
+ handles /\Aattr_(accessible|protected)(?:\s|\()/
namespace_only
def process
View
20 spec/attr_accessible_handler_spec.rb
@@ -9,7 +9,7 @@
describe "valid" do
before(:all) do
- parse_file :simple_attr_accessible
+ parse_file :attr_accessible_protected
end
it "should define reader instance method for the attr_accessible method" do
@@ -19,11 +19,19 @@
it "should define writer instance method for the attr_accessible method" do
yard('SimpleAttrAccessible#test_attribute=').should be_instance_of(CodeObjects::MethodObject)
end
+
+ it "should define reader instance method for the attr_protected method" do
+ yard('SimpleAttrAccessible#other_attribute').should be_instance_of(CodeObjects::MethodObject)
+ end
+
+ it "should define writer instance method for the attr_protected method" do
+ yard('SimpleAttrAccessible#other_attribute=').should be_instance_of(CodeObjects::MethodObject)
+ end
end
describe "legacy" do
before(:all) do
- parse_file :simple_attr_accessible, true
+ parse_file :attr_accessible_protected, true
end
it "should define reader instance method for the attr_accessible method" do
@@ -33,6 +41,14 @@
it "should define writer instance method for the attr_accessible method" do
yard('SimpleAttrAccessible#test_attribute=').should be_instance_of(CodeObjects::MethodObject)
end
+
+ it "should define reader instance method for the attr_protected method" do
+ yard('SimpleAttrAccessible#other_attribute').should be_instance_of(CodeObjects::MethodObject)
+ end
+
+ it "should define writer instance method for the attr_protected method" do
+ yard('SimpleAttrAccessible#other_attribute=').should be_instance_of(CodeObjects::MethodObject)
+ end
end
end
View
4 ...rs/examples/simple_attr_accessible.rb.txt → ...examples/attr_accessible_protected.rb.txt
@@ -1,3 +1,5 @@
class SimpleAttrAccessible
attr_accessible :test_attribute
-end
+
+ attr_protected :other_attribute
+end
Please sign in to comment.
Something went wrong with that request. Please try again.