Class: Twitter::Identity

### Home Classes Methods

### In Files

- lib/twitter/identity.rb

### Parent

Twitter::Base

### Methods

- ::fetch
- ::new
- ::store
- #==
- #id

### Class/Module Index

Quicksearch

- Twitter
- Twitter::API
- Twitter::API::Arguments
- Twitter::API::DirectMessages
- Twitter::API::Favorites
- Twitter::API::FriendsAndFollowers
- Twitter::API::Help
- Twitter::API::Lists
- Twitter::API::PlacesAndGeo
- Twitter::API::SavedSearches
- Twitter::API::Search
- Twitter::API::SpamReporting
- Twitter::API::SuggestedUsers
- Twitter::API::Timelines
- Twitter::API::Trends
- Twitter::API::Tweets
- Twitter::API::Undocumented
- Twitter::API::Users
- Twitter::API::Utils
- Twitter::Action
- Twitter::Action::Favorite
- Twitter::Action::Follow
- Twitter::Action::ListMemberAdded
- Twitter::Action::Mention
- Twitter::Action::Reply
- Twitter::Action::Retweet
- Twitter::Action::Status
- Twitter::Action::Tweet
- Twitter::ActionFactory
- Twitter::Base
- Twitter::BasicUser
- Twitter::Client
- Twitter::Configurable
- Twitter::Configuration
- Twitter::Creatable
- Twitter::Cursor
- Twitter::Default
- Twitter::DirectMessage
- Twitter::Entity
- Twitter::Entity::Hashtag
- Twitter::Entity::Url
- Twitter::Entity::UserMention
- Twitter::Error
- Twitter::Error::AlreadyFavorited
- Twitter::Error::AlreadyRetweeted
- Twitter::Error::BadGateway
- Twitter::Error::BadRequest
- Twitter::Error::ClientError
- Twitter::Error::ConfigurationError
- Twitter::Error::DecodeError
- Twitter::Error::EnhanceYourCalm
- Twitter::Error::Forbidden
- Twitter::Error::GatewayTimeout
- Twitter::Error::IdentityMapKeyError
- Twitter::Error::InternalServerError
- Twitter::Error::NotAcceptable
- Twitter::Error::NotFound
- Twitter::Error::RateLimited
- Twitter::Error::ServerError
- Twitter::Error::ServiceUnavailable
- Twitter::Error::TooManyRequests
- Twitter::Error::Unauthorized
- Twitter::Error::UnprocessableEntity
- Twitter::Exceptable
- Twitter::Factory
- Twitter::Geo
- Twitter::Geo::Point
- Twitter::Geo::Polygon
- Twitter::GeoFactory
- Twitter::Identity
- Twitter::IdentityMap
- Twitter::Language
- Twitter::List
- Twitter::Media
- Twitter::Media::Photo
- Twitter::MediaFactory
- Twitter::Metadata
- Twitter::OEmbed
- Twitter::Place
- Twitter::ProfileBanner
- Twitter::RateLimit
- Twitter::Relationship
- Twitter::Request
- Twitter::Request::MultipartWithFile
- Twitter::Response
- Twitter::Response::ParseJson
- Twitter::Response::RaiseError
- Twitter::SavedSearch
- Twitter::SearchResults
- Twitter::Settings
- Twitter::Size
- Twitter::SourceUser
- Twitter::Status
- Twitter::Suggestion
- Twitter::TargetUser
- Twitter::Trend
- Twitter::Tweet
- Twitter::User
- Twitter::Version
- Enumerable
- Kernel

No matching classes.

# Twitter::Identity

### Public Class Methods

fetch(attrs) click to toggle source

    # File lib/twitter/identity.rb, line 7
    def self.fetch(attrs)
      return unless identity_map

      id = attrs[:id]
      if id  && object = identity_map.fetch(id)
        return object.update(attrs)
      end

      return yield if block_given?
      raise Twitter::Error::IdentityMapKeyError, "key not found"
    end

new(attrs={}) click to toggle source

Initializes a new object

@param attrs [Hash] @raise [ArgumentError] Error raised when supplied argument is missing an :id key. @return [Twitter::Identity]

    # File lib/twitter/identity.rb, line 33
    def initialize(attrs={})
      super
      raise ArgumentError, "argument must have an :id key" unless id
    end

store(object) click to toggle source

Stores an object in the identity map.

@param object [Object] @return [Twitter::Identity]

    # File lib/twitter/identity.rb, line 23
    def self.store(object)
      return object unless identity_map
      identity_map.store(object.id, object)
    end

### Public Instance Methods

==(other) click to toggle source

@param other [Twitter::Identity] @return [Boolean]

    # File lib/twitter/identity.rb, line 40
    def ==(other)
      super || attr_equal(:id, other) || attrs_equal(other)
    end

id() click to toggle source

@return [Integer]

    # File lib/twitter/identity.rb, line 45
    def id
      @attrs[:id]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.