Class: Plutonium::Kanban::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/plutonium/kanban/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDSL

Returns a new instance of DSL.



12
13
14
15
16
17
18
19
20
21
# File 'lib/plutonium/kanban/dsl.rb', line 12

def initialize
  @columns = []
  @columns_block = nil
  @card_fields = nil
  @per_column = nil
  @realtime = false
  @position_config = Positioning::Config.default
  @lazy = true
  @show_in = nil
end

Class Method Details

.build(&block) ⇒ Object



6
7
8
9
10
# File 'lib/plutonium/kanban/dsl.rb', line 6

def self.build(&block)
  dsl = new
  dsl.instance_eval(&block) if block
  dsl.to_board
end

Instance Method Details

#card_fields(**slots) ⇒ Object



33
# File 'lib/plutonium/kanban/dsl.rb', line 33

def card_fields(**slots) = @card_fields = slots

#column(key, **opts, &blk) ⇒ Object



23
24
25
26
27
# File 'lib/plutonium/kanban/dsl.rb', line 23

def column(key, **opts, &blk)
  col = Column.new(key, **opts)
  col.instance_eval(&blk) if blk
  @columns << col
end

#columns(&blk) ⇒ Object

Fluent DSL setters — attr_writer would change the call syntax (per_column 25self.per_column = 25), so keep them as methods. standard:disable Style/TrivialAccessors



32
# File 'lib/plutonium/kanban/dsl.rb', line 32

def columns(&blk) = @columns_block = blk

#lazy(v = true) ⇒ Object



36
37
# File 'lib/plutonium/kanban/dsl.rb', line 36

def lazy(v = true) = @lazy = v
# standard:enable Style/TrivialAccessors

#per_column(n) ⇒ Object



34
# File 'lib/plutonium/kanban/dsl.rb', line 34

def per_column(n) = @per_column = n

#position_on(attr = :position, &blk) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/plutonium/kanban/dsl.rb', line 46

def position_on(attr = :position, &blk)
  @position_config =
    if attr == false
      Positioning::Config.disabled
    elsif blk
      Positioning::Config.with_block(attr, blk)
    else
      Positioning::Config.attribute(attr)
    end
end

#realtime(v = true) ⇒ Object



35
# File 'lib/plutonium/kanban/dsl.rb', line 35

def realtime(v = true) = @realtime = v

#show_in(mode) ⇒ Object

Overrides where a card click opens the record's show page, for this board only:

:modal — open in a centered modal dialog
:page  — navigate the whole page to the show route

When unset, the board inherits the definition's show_in (default :page).



44
# File 'lib/plutonium/kanban/dsl.rb', line 44

def show_in(mode) = @show_in = mode # standard:disable Style/TrivialAccessors

#to_boardObject



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/plutonium/kanban/dsl.rb', line 57

def to_board
  Board.new(
    columns: @columns,
    columns_block: @columns_block,
    card_fields: @card_fields,
    per_column: @per_column,
    realtime: @realtime,
    position_config: @position_config,
    lazy: @lazy,
    show_in: @show_in
  )
end