Class: Remote

Inherits:
MongoRecord show all
Defined in:
lib/yodel/models/core/site/remote.rb

Constant Summary

Constants inherited from AbstractRecord

AbstractRecord::CALLBACKS, AbstractRecord::FIELD_CALLBACKS, AbstractRecord::ORDERS

Instance Attribute Summary

Attributes inherited from AbstractRecord

#changed, #errors, #stash, #typecast, #values

Instance Method Summary collapse

Methods inherited from MongoRecord

#collection, #default_values, #fields, #id, #increment!, #inspect_hash, #load_from_mongo, #load_mongo_document, #perform_destroy, #perform_reload, #perform_save, #set_id

Methods included from MongoModel

#collection, #load, #scoped

Methods included from AbstractModel

#embed_many, #embed_one, #field, #fields, #many, #modify_field, #one, #remove_field

Methods inherited from AbstractRecord

#changed!, #changed?, #clear_key, #default_values, #destroy, #destroyed?, #eql?, #errors?, #field, #field?, #field_was, #fields, #from_json, #get, #get_meta, #get_raw, #hash, #id, #increment!, inherited, #initialize, #inspect, #inspect_hash, #inspect_value, #method_missing, #new?, #prepare_reload_params, #present?, #reload, #save, #save_without_validation, #search_terms, #set, #set_meta, #set_raw, #to_json, #to_str, #trigger_field_callback, #update, #valid?

Constructor Details

This class inherits a constructor from AbstractRecord

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AbstractRecord

Instance Method Details

#create_siteObject



13
14
15
# File 'lib/yodel/models/core/site/remote.rb', line 13

def create_site
  perform_request('/sites.json', :post)
end

#git_url(remote_id) ⇒ Object



27
28
29
30
31
32
# File 'lib/yodel/models/core/site/remote.rb', line 27

def git_url(remote_id)
  git_url = URI.parse(url).merge("/git/#{remote_id}")
  git_url.user = CGI.escape(username)
  git_url.password = password
  git_url.to_s
end

#hash_passwordObject



18
19
20
21
# File 'lib/yodel/models/core/site/remote.rb', line 18

def hash_password
  return unless password_changed? && password?
  self.password = Password.hashed_password(nil, password)
end

#hostObject



23
24
25
# File 'lib/yodel/models/core/site/remote.rb', line 23

def host
  URI.parse(url).host
end

#site_listObject



9
10
11
# File 'lib/yodel/models/core/site/remote.rb', line 9

def site_list
  perform_request('/sites.json', :get)
end