still doing attr_reader, but closing #25

cattr still missing, but only one occurence. Later.
This commit is contained in:
Torsten Ruger
2019-03-07 11:00:18 +02:00
parent 5ed6a07083
commit 1391667f6c
4 changed files with 30 additions and 33 deletions

View File

@ -39,13 +39,15 @@ module Ruby
unless class_send.is_a?(SendStatement)
raise "Other than methods, only class methods allowed, not #{class_send.class}"
end
unless class_send.name == :attr
raise "Only remapping attr and cattr, not #{class_send.name}"
allowed = [:attr , :attr_reader]
attr_name = class_send.name
unless allowed.include?(attr_name)
raise "Only remapping #{allowed}, not #{attr_name}"
end
methods = []
class_send.arguments.each do |attr|
methods << getter_for(attr.value)
methods << setter_for(attr.value)
methods << setter_for(attr.value) if attr_name == :attr
end
methods
end