5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/freighthopper/antonym_accessor.rb', line 5
def antonym_accessor(*args)
if 2 == args.length
from, to = args
define_method("#{to}?") { not send "#{from}?" }
define_method("#{to}=") {|val| send "#{from}=", ! val }
elsif args.singular.is_a?(Hash)
args.singular.each {|from, to| antonym_accessor from, to}
else
message = " antonym_accessor expects either\n \"antonym_accessor :from, :to\"\n or \"antonym_accessor :from => :to\"\n EXCEPTION\n\n raise message.unindent\n end\nend\n"
|