Class: Terminal
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Terminal
- Includes:
- Redis::Objects::RMap
- Defined in:
- app/models/terminal.rb
Constant Summary collapse
- HARDWARE =
%w(cash_acceptor modem printer card_reader watchdog)
- ORDERS =
%w(reload reboot disable enable upgrade)
Class Method Summary collapse
-
.as_hash(fields) ⇒ Object
METHODS.
Instance Method Summary collapse
Class Method Details
.as_hash(fields) ⇒ Object
METHODS
48 49 50 51 52 |
# File 'app/models/terminal.rb', line 48 def self.as_hash(fields) connection.select_all(select(fields).arel).each do |attrs| yield(attrs) if block_given? end end |
Instance Method Details
#order!(keyword, *args) ⇒ Object
93 94 95 |
# File 'app/models/terminal.rb', line 93 def order!(keyword, *args) TerminalOrder.create!(:terminal_id => id, :keyword => keyword, :args => args) end |
#ping!(data) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/models/terminal.rb', line 58 def ping!(data) raise ActiveRecord::RecordInvalid unless data.valid? pings.unshift data update = { :state => data.state, :condition => data.condition, :notified_at => data.created_at, :version => data.version, :banknotes => data.banknotes, :cash => data.cash, :cashless => data.cashless, :ip => data.ip, } HARDWARE.each do |device| update["#{device}_error"] = data.error(device) update["#{device}_model"] = data.value('model', device) update["#{device}_version"] = data.value('version', device) end update["modem_signal_level"] = data.value('signal_level', 'modem') update["modem_balance"] = data.value('balance', 'modem') if data.ok? update[:issues_started_at] = nil else update[:issues_started_at] = DateTime.now if issues_started_at.blank? end self.without_versioning do update_attributes update end end |
#title ⇒ Object
54 55 56 |
# File 'app/models/terminal.rb', line 54 def title keyword end |