Sha256: 9bb7e82882809c576919e2ddc5e3ca4d4a2ab5cfa4782bec0e11d76fc2e90fce

Contents?: true

Size: 929 Bytes

Versions: 174

Compression:

Stored size: 929 Bytes

Contents

require 'travis/client'

module Travis
  module Client
    class Account < Entity
      attributes :name, :login, :type, :repos_count, :subscribed

      one :account
      many :accounts

      inspect_info :login
      id_field :login

      def self.cast_id(id)
        String(id)
      end

      def self.id?(object)
        object.is_a? String
      end

      def subscribed
        load_attribute('subscribed') { true } if member?
      end

      def repos_count
        load_attribute("repos_count") { repositories.count }
      end

      def repositories
        attributes['repositories'] ||= session.repos(:owner_name => login)
      end

      def member?
        session.accounts.include? self
      end

      private

        def load_attribute(name, &block)
          session.accounts if missing? name
          block ? attributes.fetch(name.to_s, &block) : attributes[name.to_s]
        end
    end
  end
end

Version data entries

174 entries across 174 versions & 1 rubygems

Version Path
travis-1.6.8.travis.456.6 lib/travis/client/account.rb
travis-1.6.8.travis.455.6 lib/travis/client/account.rb
travis-1.6.8.travis.454.6 lib/travis/client/account.rb
travis-1.6.8.travis.453.6 lib/travis/client/account.rb
travis-1.6.8.travis.452.6 lib/travis/client/account.rb
travis-1.6.8.travis.451.6 lib/travis/client/account.rb
travis-1.6.8.travis.450.6 lib/travis/client/account.rb
travis-1.6.8.travis.449.6 lib/travis/client/account.rb
travis-1.6.8.travis.447.6 lib/travis/client/account.rb
travis-1.6.7.travis.446.6 lib/travis/client/account.rb
travis-1.6.7 lib/travis/client/account.rb
travis-1.6.7.travis.445.6 lib/travis/client/account.rb
travis-1.6.7.travis.443.6 lib/travis/client/account.rb
travis-1.6.7.travis.442.6 lib/travis/client/account.rb
travis-1.6.7.travis.441.6 lib/travis/client/account.rb
travis-1.6.7.travis.434.6 lib/travis/client/account.rb
travis-1.6.7.travis.431.6 lib/travis/client/account.rb
travis-1.6.7.travis.428.9 lib/travis/client/account.rb
travis-1.6.7.travis.427.9 lib/travis/client/account.rb
travis-1.6.7.travis.426.8 lib/travis/client/account.rb