Method: Megam::AccountCollection#lookup

Defined in:
lib/megam/core/account_collection.rb

#lookup(accounts) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/megam/core/account_collection.rb', line 73

def lookup(accounts)
    lookup_by = nil
    if accounts.kind_of?(Hash)
        lookup_by = accounts[:email]
    elsif accounts.kind_of?(String)
        lookup_by = accounts
    else
        raise ArgumentError, "Must pass a Megam::Account or String to lookup"
    end
    res = @accounts_by_name[lookup_by]
    unless res
        raise ArgumentError, "Cannot find a node matching #{lookup_by} (did you define it first?)"
    end
    @accounts[res]
end