Module: Twitter::EasyClassMaker

Included in:
DirectMessage, RateLimitStatus, Status, User
Defined in:
lib/twitter/easy_class_maker.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
# File 'lib/twitter/easy_class_maker.rb', line 7

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#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.bar = 'another thing'

end

Yields:

  • (_self)

Yield Parameters:



39
40
41
# File 'lib/twitter/easy_class_maker.rb', line 39

def initialize
  yield self if block_given?
end