Permalink
Browse files

rdoc

  • Loading branch information...
1 parent 35d8060 commit 3b69148df48bf2b593495821aa2f148f39e21205 @rubiii committed Oct 25, 2009
View
7 lib/validatable_associations.rb
@@ -20,8 +20,8 @@ def self.included(base) #:nodoc:
end
# Catches calls to undefined methods. Checks if the +method+ called matches
- # a reader/writer method of an association and handles the read/write process.
- # Delegates to super otherwise.
+ # an association or a method for validates_confirmation_of. Delegates to super
+ # otherwise.
def method_missing(method, *args)
method = clean_method_name(method)
@@ -38,8 +38,7 @@ def method_missing(method, *args)
private
- # Expects the name of a reader/writer +method+ and turns it into a valid
- # name for an association.
+ # Removes the writer attribute ("=") from a given +method+.
def clean_method_name(method)
name = method.to_s
name.slice! -1 if name[-1, 1] == "="
View
1 lib/validatable_associations/association.rb
@@ -28,6 +28,7 @@ def association?(method_name)
self.class.has_one.include? method_name
end
+ # Handles a call to an association.
def handle_association(association_name, argument)
association_to_set = find_or_create_association(association_name, argument)
self.instance_variable_set("@#{association_name}", association_to_set)
View
2 lib/validatable_associations/confirmation.rb
@@ -3,6 +3,7 @@ module Confirmation
private
+ # Returns whether a given +method_name+ matches a confirmation.
def confirmation?(method_name)
if method_name[-13, 13] == "_confirmation"
method = method_name.dup
@@ -14,6 +15,7 @@ def confirmation?(method_name)
self.public_methods.include? method
end
+ # Handles a call to a confirmation.
def handle_confirmation(confirmation, argument)
return self.instance_variable_get("@#{confirmation}") unless argument
View
2 lib/validatable_associations/has_one.rb
@@ -4,7 +4,7 @@ module HasOne
module ClassMethods
# Reader/writer method for has_one associations. Sets 1-n +associations+
- # or defaults to return all previously specified associations if no
+ # or defaults to returning all previously specified associations if no
# parameters were given.
def has_one(*associations)
@has_one = [] unless @has_one
View
6 lib/validatable_associations/mass_assignment.rb
@@ -2,7 +2,7 @@ module ValidatableAssociations
module MassAssignment
# The initialize method handles mass-assignment of a given Hash of
- # +attributes+ to their instance variables.
+ # +attributes+ to their corresponding instance variables.
def initialize(attributes = {})
return if !attributes || attributes.empty?
attributes.each { |ivar, value| assign_to(ivar, value) }
@@ -11,8 +11,8 @@ def initialize(attributes = {})
private
# Assigns a given +value+ to a given +ivar+. Tries to use the writer method
- # for the given instance variable and defaults to setting it directly in case
- # no writer method was found.
+ # for the given instance variable and falls back on setting it directly in
+ # case no writer method was found.
def assign_to(ivar, value)
if assign_via_writer? ivar
self.send("#{ivar}=", value)

0 comments on commit 3b69148

Please sign in to comment.