Module: Tiqbi::Qiita

Extended by:
Qiita
Included in:
Qiita
Defined in:
lib/tiqbi/qiita.rb

Instance Method Summary collapse

Instance Method Details

#get(method, *args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/tiqbi/qiita.rb', line 8

def get(method, *args)
  cache_key = "#{method}_#{args.join('_')}"
  unless Tiqbi.cache.exist?(cache_key)
    data = ::Qiita.send(method, *args) rescue nil
    Tiqbi.cache.write(cache_key, data.dup) if data
  else
    data = Tiqbi.cache.read(cache_key).dup
  end
  data
end

#item(uuid) ⇒ Object



22
23
24
# File 'lib/tiqbi/qiita.rb', line 22

def item(uuid)
  get(:item, uuid) || {}
end

#itemsObject



19
20
21
# File 'lib/tiqbi/qiita.rb', line 19

def items
  get(:item, "") || []
end