Class: Jira::Auto::Tool::Board::Cache
- Defined in:
- lib/jira/auto/tool/board/cache.rb
Instance Attribute Summary collapse
-
#tool ⇒ Object
readonly
Returns the value of attribute tool.
Instance Method Summary collapse
- #boards ⇒ Object
- #clear ⇒ Object
-
#initialize(tool) ⇒ Cache
constructor
A new instance of Cache.
- #save(boards) ⇒ Object
- #valid? ⇒ Boolean
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
#tool ⇒ Object (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
#boards ⇒ Object
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 |
#clear ⇒ Object
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
36 37 38 |
# File 'lib/jira/auto/tool/board/cache.rb', line 36 def valid? File.exist?(file_path) && !expired? end |