Permalink
Browse files

Updated Attribute class methods to be command methods

  • Loading branch information...
1 parent 48e7244 commit 8e68a2a0ea020b21ac4bc758ce82f511cd7f6177 @dkubb dkubb committed Jul 8, 2011
Showing with 6 additions and 7 deletions.
  1. +6 −7 lib/virtus/attribute.rb
View
@@ -125,7 +125,7 @@ def self.accept_options(*new_options)
concat_options(new_options)
new_options.each { |option| add_option_method(option) }
descendants.each { |descendant| descendant.concat_options(new_options) }
- accepted_options
+ self
end
# Adds a reader/writer method for the give option name
@@ -149,27 +149,27 @@ def self.#{option}(value = Undefined) # def self.unique(value = Undefin
# @param [#to_hash] new_options
# options to be set
#
- # @return [Hash]
- # default options set on the attribute class
+ # @return [self]
#
# @api private
def self.set_options(new_options)
new_options.to_hash.each do |option_name, option_value|
send(option_name, option_value)
end
+ self
end
# Adds new options that an attribute class can accept
#
# @param [#to_ary] new_options
# new options to be added
#
- # @return [Array]
- # all accepted options
+ # @return [self]
#
# @api private
def self.concat_options(new_options)
accepted_options.concat(new_options.to_ary).uniq
+ self
end
# Adds descendant to descendants array and inherits default options
@@ -181,8 +181,7 @@ def self.concat_options(new_options)
# @api private
def self.inherited(descendant)
super
- descendant.concat_options(accepted_options)
- descendant.set_options(options)
+ descendant.concat_options(accepted_options).set_options(options)
self
end

0 comments on commit 8e68a2a

Please sign in to comment.