Class: Avo::Licensing::License
- Inherits:
-
Object
- Object
- Avo::Licensing::License
show all
- Defined in:
- lib/avo/licensing/license.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(response = {}) ⇒ License
Returns a new instance of License.
9
10
11
12
13
14
|
# File 'lib/avo/licensing/license.rb', line 9
def initialize(response = {})
@response = response
@id = response["id"]
@valid = response["valid"]
@payload = response["payload"]
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4
5
6
|
# File 'lib/avo/licensing/license.rb', line 4
def id
@id
end
|
#payload ⇒ Object
Returns the value of attribute payload.
7
8
9
|
# File 'lib/avo/licensing/license.rb', line 7
def payload
@payload
end
|
#response ⇒ Object
Returns the value of attribute response.
5
6
7
|
# File 'lib/avo/licensing/license.rb', line 5
def response
@response
end
|
#valid ⇒ Object
Returns the value of attribute valid.
6
7
8
|
# File 'lib/avo/licensing/license.rb', line 6
def valid
@valid
end
|
Instance Method Details
#abilities ⇒ Object
40
41
42
|
# File 'lib/avo/licensing/license.rb', line 40
def abilities
[]
end
|
#advanced? ⇒ Boolean
28
29
30
|
# File 'lib/avo/licensing/license.rb', line 28
def advanced?
id == "advanced"
end
|
#can(ability) ⇒ Object
Also known as:
has
44
45
46
|
# File 'lib/avo/licensing/license.rb', line 44
def can(ability)
abilities.include? ability
end
|
#cant(ability) ⇒ Object
Also known as:
lacks
48
49
50
|
# File 'lib/avo/licensing/license.rb', line 48
def cant(ability)
!can ability
end
|
#error ⇒ Object
32
33
34
|
# File 'lib/avo/licensing/license.rb', line 32
def error
@response["error"]
end
|
#has_with_trial(ability) ⇒ Object
Returns if has ability and if is a valid license or app is in development.
56
57
58
59
60
|
# File 'lib/avo/licensing/license.rb', line 56
def has_with_trial(ability)
return can(ability) && valid? if Rails.env.production?
true
end
|
#invalid? ⇒ Boolean
20
21
22
|
# File 'lib/avo/licensing/license.rb', line 20
def invalid?
!valid?
end
|
#lacks_with_trial(ability) ⇒ Object
Returns if lacks ability and if is a valid license or app is in development.
63
64
65
|
# File 'lib/avo/licensing/license.rb', line 63
def lacks_with_trial(ability)
!has_with_trial ability
end
|
#name ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/avo/licensing/license.rb', line 67
def name
if id.present?
id.humanize
else
self.class.to_s.split("::").last.underscore.humanize.gsub " license", ""
end
end
|
#pro? ⇒ Boolean
24
25
26
|
# File 'lib/avo/licensing/license.rb', line 24
def pro?
id == "pro"
end
|
#properties ⇒ Object
36
37
38
|
# File 'lib/avo/licensing/license.rb', line 36
def properties
@response.slice("valid", "id", "error").symbolize_keys
end
|
#valid? ⇒ Boolean
16
17
18
|
# File 'lib/avo/licensing/license.rb', line 16
def valid?
valid
end
|