Class: TableCloth::Extensions::Actions::Jury

Inherits:
Object
  • Object
show all
Defined in:
lib/table_cloth/extensions/actions/jury.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action) ⇒ Jury

Returns a new instance of Jury.



5
6
7
# File 'lib/table_cloth/extensions/actions/jury.rb', line 5

def initialize(action)
  @action = action
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



3
4
5
# File 'lib/table_cloth/extensions/actions/jury.rb', line 3

def action
  @action
end

Instance Method Details

#available?(object) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/table_cloth/extensions/actions/jury.rb', line 9

def available?(object)
  case action_if
  when Proc
    return !!action_if.call(object)
  when Symbol
    return !!object.send(action_if)
  end

  case action_unless
  when Proc
    return !action_unless.call(object)
  when Symbol
    return !object.send(action_unless)
  end

  return true
end