Class: Cartridge

Inherits:
RestApi::Base show all
Includes:
Comparable
Defined in:
app/models/cartridge.rb

Overview

The REST API model object representing a cartridge instance.

Defined Under Namespace

Classes: BuildRelation, ScaleRelation

Instance Attribute Summary collapse

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 Attribute Details

#gearsObject (readonly)

Returns the value of attribute gears.



19
20
21
# File 'app/models/cartridge.rb', line 19

def gears
  @gears
end

#git_urlObject

Returns the value of attribute git_url.



18
19
20
# File 'app/models/cartridge.rb', line 18

def git_url
  @git_url
end

#ssh_stringObject

Returns the value of attribute ssh_string.



18
19
20
# File 'app/models/cartridge.rb', line 18

def ssh_string
  @ssh_string
end

#ssh_urlObject

Returns the value of attribute ssh_url.



18
19
20
# File 'app/models/cartridge.rb', line 18

def ssh_url
  @ssh_url
end

Instance Method Details

#<=>(other) ⇒ Object



94
95
96
97
# File 'app/models/cartridge.rb', line 94

def <=>(other)
  return 0 if name == other.name
  cartridge_type <=> other.cartridge_type
end

#buildable?Boolean

The build attributes are used for view manipulation only

deprecated

Returns:

  • (Boolean)


77
78
79
# File 'app/models/cartridge.rb', line 77

def buildable?
  git_url.present? and tags.include? :web_framework
end

#buildsObject



80
81
82
# File 'app/models/cartridge.rb', line 80

def builds
  @builds || BuildRelation::Null
end

#builds?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'app/models/cartridge.rb', line 83

def builds?
  @builds.present?
end

#builds_with(cart, gear_group) ⇒ Object



86
87
88
# File 'app/models/cartridge.rb', line 86

def builds_with(cart, gear_group)
  @builds = BuildRelation.new cart, gear_group.is_a?(String) ? gear_group : gear_group.name
end

#cartridge_typeObject



99
100
101
# File 'app/models/cartridge.rb', line 99

def cartridge_type
  @cartridge_type ||= CartridgeType.cached.find(name)
end

#collocated_withObject



29
30
31
# File 'app/models/cartridge.rb', line 29

def collocated_with
  @attributes[:collocated_with] ||= []
end

#gear_countObject



53
54
55
# File 'app/models/cartridge.rb', line 53

def gear_count
  @gears.length
end

#groupingObject



90
91
92
# File 'app/models/cartridge.rb', line 90

def grouping
  @grouping ||= [name].concat(collocated_with).uniq.sort
end

#runs_on(new_gears) ⇒ Object



47
48
49
# File 'app/models/cartridge.rb', line 47

def runs_on(new_gears)
  gears.concat(new_gears)
end

#scalesObject

deprecated



58
59
60
# File 'app/models/cartridge.rb', line 58

def scales
  @scales || ScaleRelation::Null
end

#scales?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/models/cartridge.rb', line 62

def scales?
  @scales.present? || supported_scales_from != supported_scales_to
end

#scales_with(*args) ⇒ Object

deprecated with args



67
68
69
70
71
# File 'app/models/cartridge.rb', line 67

def scales_with(*args)
  args.length == 0 ? super : begin
    @scales = ScaleRelation.new args[0], args[1].is_a?(String) ? args[1] : args[1].name, args[2]
  end
end

#supported_scales_fromObject



33
34
35
# File 'app/models/cartridge.rb', line 33

def supported_scales_from
  super || 1
end

#supported_scales_toObject



36
37
38
# File 'app/models/cartridge.rb', line 36

def supported_scales_to
  super || 1
end

#typeObject



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

def type
  @attributes[:type]
end

#type=(type) ⇒ Object



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

def type=(type)
  @attributes[:type]=type
end