Class: Consent::View

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of View.



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

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.



3
4
5
# File 'lib/consent/view.rb', line 3

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label.



3
4
5
# File 'lib/consent/view.rb', line 3

def label
  @label
end

Instance Method Details

#conditions(*args) ⇒ Object



12
13
14
15
# File 'lib/consent/view.rb', line 12

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

#object_conditions(*args) ⇒ Object



17
18
19
20
# File 'lib/consent/view.rb', line 17

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