Sha256: 60bf43adda689f3545665fcd07f886f372eb1bab04b93188f870ba617441afa2
Contents?: true
Size: 517 Bytes
Versions: 15
Compression:
Stored size: 517 Bytes
Contents
class SiteHub module GetterSetterMethods def getter_setters(*method_names) method_names.each do |method_name| getter_setter method_name.to_sym end end def getter_setter(method_name, default = nil) define_method method_name do |arg = nil| attribute_name = "@#{method_name}" if arg instance_variable_set(attribute_name, arg) self else instance_variable_get(attribute_name) || default end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems