Method: Needish::EasyClassMaker#initialize
- Defined in:
- lib/needish/easy_class_maker.rb
#initialize {|_self| ... } ⇒ Object
allows for any class that includes this to use a block to initialize variables instead of assigning each one seperately
Example:
instead of…
s = Status.new s.foo = ‘thing’ s.bar = ‘another thing’
you can …
Status.new do |s|
s.foo = 'thing'
s. = 'another thing'
end
39 40 41 |
# File 'lib/needish/easy_class_maker.rb', line 39 def initialize yield self if block_given? end |