Class: Consent::Subject

Inherits:
Object
  • Object
show all
Defined in:
lib/consent/subject.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

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)
  @key = key
  @label = label
  @actions = []
  @views = Consent.default_views.clone
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



5
6
7
# File 'lib/consent/subject.rb', line 5

def actions
  @actions
end

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/consent/subject.rb', line 5

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label.



5
6
7
# File 'lib/consent/subject.rb', line 5

def label
  @label
end

#viewsObject (readonly)

Returns the value of attribute views.



5
6
7
# File 'lib/consent/subject.rb', line 5

def views
  @views
end

Instance Method Details

#permission_keyObject



14
15
16
# File 'lib/consent/subject.rb', line 14

def permission_key
  ActiveSupport::Inflector.underscore(@key.to_s).to_sym
end

#view_for(action, key) ⇒ Object



18
19
20
21
# File 'lib/consent/subject.rb', line 18

def view_for(action, key)
  view = @views.keys & action.view_keys & [key]
  @views[view.first] || @views[action.default_view]
end