lib/travis/client/account.rb in travis-1.5.6.travis.297.4 vs lib/travis/client/account.rb in travis-1.5.6.travis.299.4

- old
+ new

@@ -7,12 +7,40 @@ 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 - attributes.fetch('subscribed') { true } + 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