Class: Consent::View

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, label, instance = nil, collection = nil) ⇒ View

Returns a new instance of View.



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

def initialize(key, label, instance = nil, collection = nil)
  @key = key
  @label = label
  @instance = instance
  @collection = collection
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label.



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

def label
  @label
end

Instance Method Details

#conditions(*args) ⇒ Object



14
15
16
17
18
# File 'lib/consent/view.rb', line 14

def conditions(*args)
  return @collection unless @collection.respond_to?(:call)

  @collection.call(*args)
end

#object_conditions(*args) ⇒ Object



20
21
22
23
24
# File 'lib/consent/view.rb', line 20

def object_conditions(*args)
  return @instance unless @instance.respond_to?(:curry)

  @instance.curry[*args]
end