Class: ApplicationTemplate

Inherits:
RestApi::Base show all
Defined in:
app/models/application_template.rb

Instance Method Summary collapse

Methods inherited from RestApi::Base

alias_attribute, aliased_attributes, allow_anonymous?, #as, #as=, #assign_attributes, attr_alters, #attributes=, calculated_attributes, #clone, configuration=, connection, custom_id, delete, #dup, #duplicate_errors, element_path, exception_for_code, find, find_one, get, #get, #has_exit_code?, headers, #initialize, #load, #load_remote_errors, on_exit_code, #raise_on_invalid, #reload, remote_errors_for, #remote_results, #save!, #save_with_change_tracking, shared_connection, singleton?, #to_json, translate_api_error, use_patch_on_update?, #valid?

Methods included from ActiveResource::Associations

#belongs_to, #has_many, #has_one

Constructor Details

This class inherits a constructor from RestApi::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RestApi::Base

Instance Method Details

#cartridgesObject



70
71
72
# File 'app/models/application_template.rb', line 70

def cartridges
  @cartridges ||= descriptor['Requires'] || []
end

#credentialsObject



43
44
45
46
# File 'app/models/application_template.rb', line 43

def credentials
  creds = .attributes[:credentials]
  creds.map{|x| x.attributes.to_hash } unless creds.nil?
end

#credentials_messageObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/application_template.rb', line 48

def credentials_message
  creds = credentials
  return if creds.blank?

  str =  "Your application contains pre-configured accounts, here are their credentials. " +
         "You may want to change them as soon as possible.\n"

  credentials.each do |cred|
    str << "\n"
    [:username, :password].each do |type|
      str << "%s: %s\n" % [type.to_s.upcase,cred[type.to_s]]
    end
  end

  str
end

#descriptorObject



23
24
25
# File 'app/models/application_template.rb', line 23

def descriptor
  @descriptor ||= YAML.load(descriptor_yaml) || {}
end

#display_nameObject



27
28
29
# File 'app/models/application_template.rb', line 27

def display_name
  attributes['display_name'] || name
end

#initial_git_branchObject



75
76
77
# File 'app/models/application_template.rb', line 75

def initial_git_branch
  nil
end

#providesObject



35
36
37
# File 'app/models/application_template.rb', line 35

def provides
  Array(super)
end

#scalableObject Also known as: scalable?



65
66
67
# File 'app/models/application_template.rb', line 65

def scalable
  false
end

#tagsObject Also known as: categories



30
31
32
# File 'app/models/application_template.rb', line 30

def tags
  @tags ||= super.map{|t| t.to_sym} << :template
end

#templateObject



39
40
41
# File 'app/models/application_template.rb', line 39

def template
  self
end