Module: GooglePlus::Entity

Included in:
Activity, Comment, EntityHash, Person, RequestError
Defined in:
lib/google_plus/entity.rb

Overview

A mixin that allows retrieval of nested attributes

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments, &block) ⇒ Object

Access an attribute of the Entity



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/google_plus/entity.rb', line 13

def method_missing(method, *arguments, &block)
  method_s = method.to_s
  if @attributes.has_key?(method_s)
    val = @attributes[method_s]
    if val.is_a?(Hash)
      GooglePlus::EntityHash.new @attributes[method_s]
    else
      val
    end
  else
    super
  end
end

Instance Attribute Details

#attributesObject (readonly)

The raw accessible attributes



38
39
40
# File 'lib/google_plus/entity.rb', line 38

def attributes
  @attributes
end

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
# File 'lib/google_plus/entity.rb', line 6

def self.included(base)
  base.instance_eval do
    undef_method :id if method_defined? :id
  end
end

Instance Method Details

#respond_to?(method, include_private = false) ⇒ Boolean

Determine if an attribute is set on the Entity

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
# File 'lib/google_plus/entity.rb', line 28

def respond_to?(method, include_private = false)
  method_s = method.to_s
  if @attributes.has_key?(method_s)
    true
  else
    super
  end
end