Module: AttrWithDefault::ClassMethods

Defined in:
lib/attr_with_default.rb

Instance Method Summary collapse

Instance Method Details

#attr_accessor(*args) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/attr_with_default.rb', line 7

def attr_accessor(*args)
  attrs, attrs_with_defaults = split_for_last_hash(args)
  attrs_with_defaults.each do |name, default|
    attr_reader_with_default name, default
    attr_writer              name
  end
  
  super(*attrs)
end

#attr_reader(*args) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/attr_with_default.rb', line 17

def attr_reader(*args)
  attrs, attrs_with_defaults = split_for_last_hash(args)
  attrs_with_defaults.each do |name, default|
    attr_reader_with_default name, default
  end
  
  super(*attrs)
end