Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 39 lines (34 sloc) 0.911 kb
b92b0ca @sferik Add User, Status, Place, Point, and Polygon classes
authored
1 module Twitter
2 class Base
918aca1 @sferik Rename @attributes to @attrs to avoid collision with Twitter::Place#a…
authored
3 attr_accessor :attrs
4 alias :to_hash :attrs
1dd37f2 @sferik Method spacing
authored
5
9e032aa @sferik Flesh out YARD documentation
authored
6 # Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key
7 #
8 # @overload self.lazy_attr_reader(attr)
9 # @param attr [Symbol]
10 # @overload self.lazy_attr_reader(attrs)
11 # @param attrs [Array<Symbol>]
918aca1 @sferik Rename @attributes to @attrs to avoid collision with Twitter::Place#a…
authored
12 def self.lazy_attr_reader(*attrs)
13 attrs.each do |attribute|
6732706 @sferik Actually, ivar assignment/caching is unnecessary
authored
14 class_eval do
15 define_method attribute do
eade817 @sferik The instance variable is static, so there's no need to use instance_v…
authored
16 @attrs[attribute.to_s]
6fb7b3f @sferik Implement lazy attribute setting
authored
17 end
6732706 @sferik Actually, ivar assignment/caching is unnecessary
authored
18 end
b92b0ca @sferik Add User, Status, Place, Point, and Polygon classes
authored
19 end
20 end
21
9e032aa @sferik Flesh out YARD documentation
authored
22 # Initializes a new Base object
23 #
24 # @param attrs [Hash]
25 # @return [Twitter::Base]
26 def initialize(attrs={})
918aca1 @sferik Rename @attributes to @attrs to avoid collision with Twitter::Place#a…
authored
27 @attrs = attrs.dup
d63d2e5 @sferik Allow [] access to methods for greater backwards compatibility
authored
28 end
29
9e032aa @sferik Flesh out YARD documentation
authored
30 # Initializes a new Base object
31 #
32 # @param method [String, Symbol] Message to send to the object
6fb7b3f @sferik Implement lazy attribute setting
authored
33 def [](method)
34 self.__send__(method.to_sym)
cc1e2e4 @sferik Add #user method to Status class
authored
35 end
1dd37f2 @sferik Method spacing
authored
36
b92b0ca @sferik Add User, Status, Place, Point, and Polygon classes
authored
37 end
38 end
Something went wrong with that request. Please try again.