Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Compute site late when we have all data.
  • Loading branch information
krekoten committed Sep 23, 2010
1 parent 691db89 commit db6c98a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
12 changes: 2 additions & 10 deletions lib/lighthouse.rb
Expand Up @@ -49,16 +49,8 @@ class Error < StandardError; end
class Change < Array; end

class << self
attr_accessor :email, :password, :host_format, :domain_format, :protocol, :port
attr_reader :account, :token

# Sets the account name, and updates all the resources with the new domain.
def account=(name)
@account = name
resources.each do |klass|
update_site(klass)
end
end
attr_accessor :account, :email, :password, :host_format, :domain_format, :protocol, :port
attr_reader :token

# Sets up basic authentication credentials for all the resources.
def authenticate(email, password)
Expand Down
9 changes: 7 additions & 2 deletions lib/lighthouse/base.rb
Expand Up @@ -2,12 +2,17 @@ module Lighthouse
class Base < ActiveResource::Base
def self.inherited(base)
Lighthouse.resources << base
class << base
class << base
attr_accessor :site_format

def site_with_update
Lighthouse.update_site(self)
site_without_update
end
alias_method_chain :site, :update
end
base.site_format = '%s'
super
Lighthouse.update_site(base)
Lighthouse.update_token_header(base)
Lighthouse.update_auth(base)
end
Expand Down
6 changes: 1 addition & 5 deletions lib/lighthouse/project_membership.rb
@@ -1,11 +1,7 @@
module Lighthouse
class ProjectMembership < Base
self.element_name = 'membership'
site_format << '/projects/:project_id'

def url
respond_to?(:account) ? account : project
end
self.site_format << "/projects/:project_id"

def save
raise Error, "Cannot modify memberships from the API"
Expand Down

0 comments on commit db6c98a

Please sign in to comment.