Class: AliceInvoice::Cache::Lazy

Inherits:
Object
  • Object
show all
Defined in:
lib/alice_invoice/cache/lazy.rb

Constant Summary collapse

SUPPORTED_API_VERSIONS =
[ 1 ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Lazy

Returns a new instance of Lazy.


8
9
10
# File 'lib/alice_invoice/cache/lazy.rb', line 8

def initialize(options = {})
  @debug = options[:debug]
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug


6
7
8
# File 'lib/alice_invoice/cache/lazy.rb', line 6

def debug
  @debug
end

Instance Method Details

#event(type, data) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/alice_invoice/cache/lazy.rb', line 16

def event(type, data)
  if @debug
    puts "===>Cache"
    puts "got event #{type} with:"
    puts "link:"         << data[:link] rescue ''
    puts "storage_path:" << data[:storage_path] rescue ''
  end

  if type == :not_in_cache
    needs_download?(data[:storage_path], data[:link])
  else
    true
  end 
end

#implements_api_version?(int) ⇒ Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/alice_invoice/cache/lazy.rb', line 12

def implements_api_version?(int)
  SUPPORTED_API_VERSIONS.include?(int)
end