Class: Consent::Action

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject, key, label, options = {}) ⇒ Action

Returns a new instance of Action.



7
8
9
10
11
12
# File 'lib/consent/action.rb', line 7

def initialize(subject, key, label, options = {})
  @subject = subject
  @key = key
  @label = label
  @options = options
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label.



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

def label
  @label
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#subjectObject (readonly)

Returns the value of attribute subject.



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

def subject
  @subject
end

Instance Method Details

#default_viewObject



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

def default_view
  return unless @options.key?(:default_view)

  @default_view ||= @subject.views[@options[:default_view]]
end

#viewsObject



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

def views
  @views ||= @subject.views.slice(*@options.fetch(:views, []))
end