Class: Jav::Licensing::License
- Inherits:
-
Object
- Object
- Jav::Licensing::License
show all
- Defined in:
- lib/jav/licensing/license.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(response = {}) ⇒ License
Returns a new instance of License.
6
7
8
9
10
11
|
# File 'lib/jav/licensing/license.rb', line 6
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/jav/licensing/license.rb', line 4
def id
@id
end
|
#payload ⇒ Object
Returns the value of attribute payload.
4
5
6
|
# File 'lib/jav/licensing/license.rb', line 4
def payload
@payload
end
|
#response ⇒ Object
Returns the value of attribute response.
4
5
6
|
# File 'lib/jav/licensing/license.rb', line 4
def response
@response
end
|
#valid ⇒ Object
Returns the value of attribute valid.
4
5
6
|
# File 'lib/jav/licensing/license.rb', line 4
def valid
@valid
end
|
Instance Method Details
#abilities ⇒ Object
33
34
35
|
# File 'lib/jav/licensing/license.rb', line 33
def abilities
[]
end
|
#can(ability) ⇒ Object
Also known as:
has
37
38
39
|
# File 'lib/jav/licensing/license.rb', line 37
def can(ability)
abilities.include? ability
end
|
#cant(ability) ⇒ Object
Also known as:
lacks
41
42
43
|
# File 'lib/jav/licensing/license.rb', line 41
def cant(ability)
!can ability
end
|
#error ⇒ Object
25
26
27
|
# File 'lib/jav/licensing/license.rb', line 25
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.
49
50
51
52
53
|
# File 'lib/jav/licensing/license.rb', line 49
def has_with_trial(ability)
return can(ability) && valid? if Rails.env.production?
true
end
|
#invalid? ⇒ Boolean
17
18
19
|
# File 'lib/jav/licensing/license.rb', line 17
def invalid?
!valid?
end
|
#lacks_with_trial(ability) ⇒ Object
Returns if lacks ability and if is a valid license or app is in development.
56
57
58
|
# File 'lib/jav/licensing/license.rb', line 56
def lacks_with_trial(ability)
!has_with_trial ability
end
|
#name ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/jav/licensing/license.rb', line 60
def name
if id.present?
id.humanize
else
self.class.to_s.split('::').last.underscore.humanize.gsub ' license', ''
end
end
|
#pro? ⇒ Boolean
21
22
23
|
# File 'lib/jav/licensing/license.rb', line 21
def pro?
id == "pro"
end
|
#properties ⇒ Object
29
30
31
|
# File 'lib/jav/licensing/license.rb', line 29
def properties
@response.slice("valid", "id", "error").symbolize_keys
end
|
#valid? ⇒ Boolean
13
14
15
|
# File 'lib/jav/licensing/license.rb', line 13
def valid?
valid
end
|