Module: ValidatableAssociations::HasOne::ClassMethods

Included in:
ClassMethods
Defined in:
lib/validatable_associations/has_one.rb

Instance Method Summary collapse

Instance Method Details

#has_one(*associations) ⇒ Object

Reader/writer method for has_one associations. Sets 1-n associations or defaults to return all previously specified associations if no parameters were given.



9
10
11
12
13
# File 'lib/validatable_associations/has_one.rb', line 9

def has_one(*associations)
  @has_one = [] unless @has_one
  return @has_one if associations.empty?
  @has_one += associations.map { |association| association.to_s }
end