Class: ZendeskAppsSupport::AppVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/zendesk_apps_support/app_version.rb

Overview

At any point in time, we support up to four versions:

* deprecated -- we will still serve apps targeting the deprecated version,
                but newly created or updated apps CANNOT target it
* sunsetting -- we will soon be removing support for this version;
                updated apps SHOULD target the current version, no new apps allowed
* current    -- we will serve apps targeting the current version;
                newly created or updated apps SHOULD target it
* future     -- we will serve apps targeting the future version;
                newly created or updates apps MAY target it, but it
                may change without notice

Constant Summary collapse

DEPRECATED =
[].freeze
SUNSETTING =
nil
CURRENT =
'2.0'
FUTURE =
nil
TO_BE_SERVED =
[DEPRECATED, SUNSETTING, CURRENT, FUTURE].flatten.compact.freeze
VALID_FOR_UPDATE =
[SUNSETTING, CURRENT, FUTURE].compact.freeze
VALID_FOR_CREATE =
[CURRENT, FUTURE].compact.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ AppVersion

Returns a new instance of AppVersion.



26
27
28
29
30
# File 'lib/zendesk_apps_support/app_version.rb', line 26

def initialize(version)
  @version = version.to_s.freeze
  @current = CURRENT
  freeze
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



24
25
26
# File 'lib/zendesk_apps_support/app_version.rb', line 24

def current
  @current
end

Instance Method Details

#==(other) ⇒ Object



72
73
74
# File 'lib/zendesk_apps_support/app_version.rb', line 72

def ==(other)
  @version == other.to_s
end

#blank?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/zendesk_apps_support/app_version.rb', line 56

def blank?
  @version.nil? || @version == ''
end

#deprecated?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/zendesk_apps_support/app_version.rb', line 44

def deprecated?
  DEPRECATED.include?(@version)
end

#obsolete?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/zendesk_apps_support/app_version.rb', line 52

def obsolete?
  !servable?
end

#present?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/zendesk_apps_support/app_version.rb', line 60

def present?
  !blank?
end

#servable?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/zendesk_apps_support/app_version.rb', line 32

def servable?
  TO_BE_SERVED.include?(@version)
end

#sunsetting?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/zendesk_apps_support/app_version.rb', line 48

def sunsetting?
  @version == SUNSETTING
end

#to_jsonObject



68
69
70
# File 'lib/zendesk_apps_support/app_version.rb', line 68

def to_json(*)
  @version.inspect
end

#to_sObject



64
65
66
# File 'lib/zendesk_apps_support/app_version.rb', line 64

def to_s
  @version
end

#valid_for_create?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/zendesk_apps_support/app_version.rb', line 40

def valid_for_create?
  VALID_FOR_CREATE.include?(@version)
end

#valid_for_update?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/zendesk_apps_support/app_version.rb', line 36

def valid_for_update?
  VALID_FOR_UPDATE.include?(@version)
end