Class: HockeyApp::Version

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Validations, ActiveModelCompliance
Defined in:
lib/hockeyapp/models/version.rb

Constant Summary collapse

ATTRIBUTES =
[:id, :notes, :shortversion, :version, :mandatory, :timestamp, :appsize,  :title, :download_url]
POST_PAYLOAD =
[:status, :ipa, :dsym, :notes_type, :notify, :tags]
NOTES_TYPES_TO_SYM =
{
    0 => :textile,
    1 => :markdown
}
NOTIFY_TO_BOOL =
{
    0 => :none,
    1 => :all_allowed,
	2 => :all
}
STATUS_TO_SYM =
{
    1 => :deny,
    2 => :allow
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveModelCompliance

#persisted?, #to_model

Constructor Details

#initialize(app, client) ⇒ Version

Returns a new instance of Version.



46
47
48
49
50
# File 'lib/hockeyapp/models/version.rb', line 46

def initialize app, client
  @app = app
  @client = client
  default_values!
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



31
32
33
# File 'lib/hockeyapp/models/version.rb', line 31

def app
  @app
end

Class Method Details

.from_hash(h, app, client) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/hockeyapp/models/version.rb', line 38

def self.from_hash(h, app, client)
  res = self.new app, client
  ATTRIBUTES.each do |attribute|
    res.send("#{attribute.to_s}=", h[attribute.to_s]) unless (h[attribute.to_s].nil?)
  end
  res
end

Instance Method Details

#crash_reasonsObject



61
62
63
# File 'lib/hockeyapp/models/version.rb', line 61

def crash_reasons
  @crash_groups ||= @app.crash_reasons.select{|crash_reason| "#{crash_reason.app_version_id}" == @id.to_s}
end

#crashesObject



57
58
59
# File 'lib/hockeyapp/models/version.rb', line 57

def crashes
  @crashes ||= @app.crashes.select{|crash| "#{crash.app_version_id}" == @id.to_s}
end

#direct_download_urlObject



66
67
68
# File 'lib/hockeyapp/models/version.rb', line 66

def direct_download_url
  url_strategy.direct_download_url
end

#install_urlObject



70
71
72
# File 'lib/hockeyapp/models/version.rb', line 70

def install_url
  url_strategy.install_url
end

#to_keyObject



53
54
55
# File 'lib/hockeyapp/models/version.rb', line 53

def to_key
  [@id] if persisted?
end