Sha256: 332d53831b68a5a9b44ae68c87eba648db725301bb5041a1b1b7c5e803340e07

Contents?: true

Size: 942 Bytes

Versions: 7

Compression:

Stored size: 942 Bytes

Contents

module Firetower
  module Accounts
    fattr(:account_fetcher) {
      Account.method(:new)
    }
    fattr(:accounts) {
      Hash.new do |hash, subdomain|
        raise "Unknown subdomain '#{subdomain}'"
      end
    }

    # Eventually advances to HookR will render all this reduundant
    def self.extended(other)
      class << other
        include HookR::Hooks
        define_hook :new_account, :subdomain, :token, :options
      end
    end

    def self.included(other)
      other.module_eval do
        include HookR::Hooks
        define_hook :new_account, :subdomain, :token, :options
      end
    end

    # Declare an account
    def account(subdomain, token, options={})
      execute_hook(:new_account, subdomain, token, options)
      accounts[subdomain] = account_fetcher.call(subdomain, token, self, options)
    end

    def find_room(subdomain, room_name)
      accounts[subdomain].rooms[room_name]
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
firetower-0.1.1 lib/firetower/accounts.rb
firetower-0.1.0 lib/firetower/accounts.rb
firetower-0.0.9 lib/firetower/accounts.rb
firetower-0.0.8 lib/firetower/accounts.rb
firetower-0.0.7 lib/firetower/accounts.rb
firetower-0.0.6 lib/firetower/accounts.rb
firetower-0.0.5 lib/firetower/accounts.rb