Class: Hiiro::Branch

Inherits:
Object
  • Object
show all
Defined in:
lib/hiiro/branch.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_table!(db) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/hiiro/branch.rb', line 7

def self.create_table!(db)
  db.create_table?(:branches) do
    primary_key :id
    String :name, null: false
    String :worktree
    String :task
    String :tmux_json   # JSON: { session, window, pane }
    String :sha
    String :note
    String :created_at
    String :updated_at
  end
end

.find_by_name(n) ⇒ Object



26
# File 'lib/hiiro/branch.rb', line 26

def self.find_by_name(n)        = where(name: n).first

.for_task(task_name) ⇒ Object



24
# File 'lib/hiiro/branch.rb', line 24

def self.for_task(task_name)    = where(task: task_name).all

.for_worktree(wt) ⇒ Object



25
# File 'lib/hiiro/branch.rb', line 25

def self.for_worktree(wt)       = where(worktree: wt).all

.orderedObject



27
# File 'lib/hiiro/branch.rb', line 27

def self.ordered                = order(Sequel.asc(:created_at))

Instance Method Details

#tmuxObject



21
# File 'lib/hiiro/branch.rb', line 21

def tmux     = Hiiro::DB::JSON.load(tmux_json) || {}

#tmux=(v) ⇒ Object



22
# File 'lib/hiiro/branch.rb', line 22

def tmux=(v) ; self.tmux_json = Hiiro::DB::JSON.dump(v); end