Class: Jira::Auto::Tool::Board::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/jira/auto/tool/board/cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tool) ⇒ Cache

Returns a new instance of Cache.



14
15
16
# File 'lib/jira/auto/tool/board/cache.rb', line 14

def initialize(tool)
  @tool = tool
end

Instance Attribute Details

#toolObject (readonly)

Returns the value of attribute tool.



12
13
14
# File 'lib/jira/auto/tool/board/cache.rb', line 12

def tool
  @tool
end

Instance Method Details

#boardsObject



18
19
20
21
22
23
24
# File 'lib/jira/auto/tool/board/cache.rb', line 18

def boards
  raise "This method should not be used since the cache is invalid" unless valid?

  @boards ||= raw_content.fetch("boards").collect do |board_info|
    Board.new(tool, tool.jira_client.Board.build(board_info))
  end
end

#clearObject



32
33
34
# File 'lib/jira/auto/tool/board/cache.rb', line 32

def clear
  FileUtils.rm_f(file_path)
end

#save(boards) ⇒ Object



26
27
28
29
30
# File 'lib/jira/auto/tool/board/cache.rb', line 26

def save(boards)
  File.write(file_path, { "boards" => boards.collect { |board| board.jira_board.attrs } }.to_yaml)

  boards
end

#valid?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/jira/auto/tool/board/cache.rb', line 36

def valid?
  File.exist?(file_path) && !expired?
end