Class: Licensee::LicenseRules
- Inherits:
-
Struct
- Object
- Struct
- Licensee::LicenseRules
show all
- Includes:
- HashHelper
- Defined in:
- lib/licensee/license_rules.rb,
lib/licensee/license_rules.rb
Overview
Normalizes rule tags from metadata into ‘Licensee::Rule` objects.
Constant Summary
collapse
- HASH_METHODS =
Rule.groups
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from HashHelper
#serialize_hash_value, #to_h
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions
5
6
7
|
# File 'lib/licensee/license_rules.rb', line 5
def conditions
@conditions
end
|
#limitations ⇒ Object
Returns the value of attribute limitations
5
6
7
|
# File 'lib/licensee/license_rules.rb', line 5
def limitations
@limitations
end
|
#permissions ⇒ Object
Returns the value of attribute permissions
5
6
7
|
# File 'lib/licensee/license_rules.rb', line 5
def permissions
@permissions
end
|
Class Method Details
.from_hash(hash) ⇒ Object
28
29
30
31
|
# File 'lib/licensee/license_rules.rb', line 28
def from_hash(hash)
ordered_array = hash.values_at(*members.map(&:to_s))
new(*ordered_array)
end
|
.from_license(license) ⇒ Object
14
15
16
|
# File 'lib/licensee/license_rules.rb', line 14
def from_license(license)
from_meta(license.meta)
end
|
18
19
20
21
22
23
24
25
26
|
# File 'lib/licensee/license_rules.rb', line 18
def from_meta(meta)
rules = {}
Rule.groups.each do |group|
rules[group] = (meta[group] || []).map do |tag|
Rule.find_by_tag_and_group(tag, group)
end
end
from_hash(rules)
end
|
Instance Method Details
#flatten ⇒ Object
34
35
36
|
# File 'lib/licensee/license_rules.rb', line 34
def flatten
members.map { |m| public_send(m) }.flatten
end
|
#key?(key) ⇒ Boolean
Also known as:
has_key?
38
39
40
|
# File 'lib/licensee/license_rules.rb', line 38
def key?(key)
members.include?(key.to_sym)
end
|