Sha256: b66234cab7e30d512f66bd8cab47ed0b9375a219135e535ba7726167d016739a

Contents?: true

Size: 735 Bytes

Versions: 2

Compression:

Stored size: 735 Bytes

Contents

module Twitter
  module_function
  def account_store
    @account_store ||= ACAccountStore.new
  end

  def account_type
    @account_type ||= self.account_store.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter)
  end

  def accounts
    @accounts ||= self.account_store.accountsWithAccountType(account_type).collect do |ac_account|
      Twitter::User.new(ac_account)
    end
  end

  def sign_in(&block)
    @sign_in_callback = block
    self.account_store.requestAccessToAccountsWithType(self.account_type,
        withCompletionHandler:lambda { |granted, error|
      # Reset accounts
      @accounts = nil
      Dispatch::Queue.main.sync {
        @sign_in_callback.call(granted, error)
      }
    })
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twittermotion-0.0.2 lib/twittermotion/twitter.rb
twittermotion-0.0.1 lib/twittermotion/twitter.rb