Class: Cliskip2::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cliskip2/base.rb

Direct Known Subclasses

Community, CommunityParticipation, User

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Twitter::Base

Initializes a new Base object

Parameters:

  • attrs (Hash) (defaults to: {})


26
27
28
# File 'lib/cliskip2/base.rb', line 26

def initialize(attrs={})
  @attrs = attrs.dup
end

Instance Attribute Details

#attrsObject

Returns the value of attribute attrs.



4
5
6
# File 'lib/cliskip2/base.rb', line 4

def attrs
  @attrs
end

Class Method Details

.self.lazy_attr_reader(attr) ⇒ Object .self.lazy_attr_reader(attrs) ⇒ Object

Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key

Overloads:

  • .self.lazy_attr_reader(attr) ⇒ Object

    Parameters:

    • attr (Symbol)
  • .self.lazy_attr_reader(attrs) ⇒ Object

    Parameters:

    • attrs (Array<Symbol>)


12
13
14
15
16
17
18
19
20
# File 'lib/cliskip2/base.rb', line 12

def self.lazy_attr_reader(*attrs)
  attrs.each do |attribute|
    class_eval do
      define_method attribute do
        @attrs[attribute.to_s]
      end
    end
  end
end