Class: Consent::Subject
- Inherits:
-
Object
- Object
- Consent::Subject
- Defined in:
- lib/consent/subject.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#views ⇒ Object
readonly
Returns the value of attribute views.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(key, label) ⇒ Subject
constructor
A new instance of Subject.
- #key ⇒ Object
- #to_permission_payload ⇒ Object
Constructor Details
#initialize(key, label) ⇒ Subject
Returns a new instance of Subject.
7 8 9 10 11 12 |
# File 'lib/consent/subject.rb', line 7 def initialize(key, label) @raw_key = key.respond_to?(:name) ? key.name : key @label = label @actions = [] @views = Consent.default_views.clone end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
5 6 7 |
# File 'lib/consent/subject.rb', line 5 def actions @actions end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
5 6 7 |
# File 'lib/consent/subject.rb', line 5 def label @label end |
#views ⇒ Object (readonly)
Returns the value of attribute views.
5 6 7 |
# File 'lib/consent/subject.rb', line 5 def views @views end |
Instance Method Details
#<=>(other) ⇒ Object
29 30 31 32 33 |
# File 'lib/consent/subject.rb', line 29 def <=>(other) key = Consent::SubjectCoder.dump(key) other_key = Consent::SubjectCoder.dump(other.key) key <=> other_key end |
#key ⇒ Object
14 15 16 |
# File 'lib/consent/subject.rb', line 14 def key Consent::SubjectCoder.load(@raw_key) end |
#to_permission_payload ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/consent/subject.rb', line 18 def actions = self.actions.sort views = self.views.values.sort { subject: key, label: label, actions: actions.map(&:to_permission_payload), views: views.map(&:to_permission_payload), } end |