Class: Devmate::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/devmate/application_controller.rb

Instance Method Summary collapse

Instance Method Details

#fetchDataObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/devmate/application_controller.rb', line 4

def fetchData
  path = File.join(Devmate::Engine.root, 'config', 'data', 'quotes.json')
  if File.exists?(path)
    quotes_file = File.read(path)
    quotes_hash = JSON.parse(quotes_file)
    test_data = Hash[ 
      :position => Devmate.position,
      :timeout => Devmate.timeout,
      :call_timeout => Devmate.call_timeout,
      :maxVisible => Devmate.maxVisible,
      :close_with => Devmate.close_with,
      :data_count => quotes_hash.length.to_s,
      :data => quotes_hash
    ]
    respond_to do |format|
      format.json {
        render json: test_data.to_json
      }
    end
  end
end