Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated Attribute methods to be command methods

  • Loading branch information...
commit 1a1da35d7a84dae6ce05b14fbda0a431c50695d3 1 parent e4cea92
@dkubb dkubb authored
Showing with 11 additions and 3 deletions.
  1. +6 −2 lib/virtus/attribute.rb
  2. +5 −1 lib/virtus/attribute/boolean.rb
View
8 lib/virtus/attribute.rb
@@ -343,7 +343,7 @@ def set!(instance, value)
# Creates an attribute reader method
#
- # @return [NilClass]
+ # @return [self]
#
# @api private
def add_reader_method(model)
@@ -362,11 +362,13 @@ def #{method_name} # d
RUBY
model.send(reader_visibility, method_name)
+
+ self
end
# Creates an attribute writer method
#
- # @return [NilClass]
+ # @return [self]
#
# @api private
def add_writer_method(model)
@@ -383,6 +385,8 @@ def #{method_name}(value) # def name=(value)
RUBY
model.send(writer_visibility, method_name)
+
+ self
end
private
View
6 lib/virtus/attribute/boolean.rb
@@ -46,7 +46,9 @@ def typecast_to_primitive(value)
# Creates standard and boolean attribute reader methods
#
- # @return [NilClass]
+ # @param [Class] model
+ #
+ # @return [self]
#
# @api private
def add_reader_method(model)
@@ -65,6 +67,8 @@ def #{method_name} # def active?
RUBY
model.send(reader_visibility, method_name)
+
+ self
end
end # class Boolean
Please sign in to comment.
Something went wrong with that request. Please try again.