Sha256: f1f3a5ece3996052d3f9a3cdc517fcd0dc911a3f7b315302401d1253c6052bcb

Contents?: true

Size: 1.11 KB

Versions: 207

Compression:

Stored size: 1.11 KB

Contents

require 'travis/client'

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

      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 education
        load_attribute('education') { false } if member?
      end

      def on_trial?
        !subscribed? and !education?
      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

      alias educational? education?

      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

207 entries across 207 versions & 3 rubygems

Version Path
travis-1.9.1 lib/travis/client/account.rb
travis-1.9.1.travis.1223.9 lib/travis/client/account.rb
travis-1.9.1.travis.1220.9 lib/travis/client/account.rb
travis-1.9.1.travis.1219.9 lib/travis/client/account.rb
travis-1.9.1.travis.1216.9 lib/travis/client/account.rb
travis-1.9.1.travis.1208.9 lib/travis/client/account.rb
travis-1.9.1.travis.1207.9 lib/travis/client/account.rb
travis-1.9.1.travis.1206.9 lib/travis/client/account.rb
travis-1.9.1.travis.1205.9 lib/travis/client/account.rb
travis-1.9.0 lib/travis/client/account.rb
travis-1.9.1.travis.1201.9 lib/travis/client/account.rb
travis-1.8.14.travis.1200.9 lib/travis/client/account.rb
travis-1.8.14.travis.1199.9 lib/travis/client/account.rb
travis-1.8.14.travis.1198.9 lib/travis/client/account.rb
travis-1.8.14.travis.1197.9 lib/travis/client/account.rb
travis-1.8.14.travis.1195.9 lib/travis/client/account.rb
travis-1.8.14.travis.1192.9 lib/travis/client/account.rb
travis-1.8.14.travis.1186.9 lib/travis/client/account.rb
travis-1.8.14.travis.1184.9 lib/travis/client/account.rb
travis-1.8.14.travis.1183.9 lib/travis/client/account.rb