Class: TableSettings::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/table_settings/table_action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_settings) ⇒ Action

Returns a new instance of Action.



5
6
7
8
9
10
# File 'lib/table_settings/table_action.rb', line 5

def initialize(table_settings)
  @table_settings = table_settings
  @action_hash = {}

  add_defaults
end

Instance Attribute Details

#action_hashObject

Returns the value of attribute action_hash.



3
4
5
# File 'lib/table_settings/table_action.rb', line 3

def action_hash
  @action_hash
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/table_settings/table_action.rb', line 3

def name
  @name
end

Instance Method Details

#action(name) ⇒ Object



27
28
29
30
# File 'lib/table_settings/table_action.rb', line 27

def action(name)
  @action_hash[:symlink_action] = name
  self
end

#add_defaultsObject



17
18
19
20
# File 'lib/table_settings/table_action.rb', line 17

def add_defaults
  @action_hash[:symlink_remote] = true
  self
end

#controller(name) ⇒ Object



22
23
24
25
# File 'lib/table_settings/table_action.rb', line 22

def controller(name)
  @action_hash[:symlink_controller] = name
  self
end

#css_class(name) ⇒ Object



51
52
53
54
# File 'lib/table_settings/table_action.rb', line 51

def css_class(name)
  @action_hash[:class] = name
  self
end

#css_class_type(type) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/table_settings/table_action.rb', line 56

def css_class_type(type)
  css=case type
        when :show then "btn btn-success"
        when :edit then "btn btn-warning"
        when :delete then "btn btn-danger"
        when :destroy then "btn btn-danger"
        else "btn"
      end
  @action_hash[:class] = css
  self
end

#http_method(name) ⇒ Object

Parameters:

  • - (Symbol|String)

    :get|:put|:post|:delete



46
47
48
49
# File 'lib/table_settings/table_action.rb', line 46

def http_method(name)
  @action_hash[:method] = name
  self
end

#label(label) ⇒ Object



12
13
14
15
# File 'lib/table_settings/table_action.rb', line 12

def label(label)
  @action_hash[:name] = label
  self
end

#outer_controller(name) ⇒ Object



31
32
33
34
# File 'lib/table_settings/table_action.rb', line 31

def outer_controller(name)
  @action_hash[:symlink_outer_controller] = name
  self
end

#outer_id(name) ⇒ Object



35
36
37
38
# File 'lib/table_settings/table_action.rb', line 35

def outer_id(name)
  @action_hash[:symlink_outer_id] = name
  self
end

#position(pos) ⇒ Object

Position of button

Parameters:

  • pos (Symbol)
    • :left | :right



71
72
73
74
# File 'lib/table_settings/table_action.rb', line 71

def position(pos)
  @action_hash[:position] = pos
  self
end

#remote(bool) ⇒ Object



40
41
42
43
# File 'lib/table_settings/table_action.rb', line 40

def remote(bool)
  @action_hash[:symlink_remote] = bool
  self
end