Class: Role
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Role
- Defined in:
- app/models/role.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.actions ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/role.rb', line 12 def self.actions @actions ||= { 'terminals' => %w(read create edit destroy reload reboot disable enable upgrade), 'monitoring' => [ 'keyword', 'address', 'printer-error', 'printer-model', 'printer-version', 'cash-acceptor-error', 'cash-acceptor-version', 'cash-acceptor-model', 'modem-error', 'modem-signal-level', 'modem-balance', 'card-reader-error', 'card-reader-version', 'card-reader-model', 'watchdog-error', 'collected-at', 'notified-at', 'issues-started-at', 'agent-id', 'terminal-profile-id', 'version', 'banknotes', 'cash', 'cashless', 'upstream', 'downstream', 'ip', 'juristic-name', 'contract-number', 'rent', 'rent-finish-date' ] } end |
.entries ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'app/models/role.rb', line 2 def self.entries @entries ||= %w( monitoring users versions reports report_templates payments providers commissions limits provider_receipt_templates terminals agents collections terminal_profiles system_receipt_templates gateways rebates revisions ) end |
.entries_actions ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/models/role.rb', line 51 def self.entries_actions return @result unless @result.blank? @result = {} entries.each do |x| @result[x] = {} if actions[x].blank? %w(read create edit destroy).each do |a| @result[x][a] = I18n.t("smartkiosk.role_priveleges.basic.#{a}") end else actions[x].each do |a| @result[x][a] = I18n.t("smartkiosk.role_priveleges.#{x}.#{a}") end end end @result end |
Instance Method Details
#actions ⇒ Object
82 83 84 |
# File 'app/models/role.rb', line 82 def actions self.class.entries_actions[keyword] end |
#modelize ⇒ Object
86 87 88 |
# File 'app/models/role.rb', line 86 def modelize keyword.singularize.camelize.constantize rescue nil end |
#title ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'app/models/role.rb', line 72 def title roles = I18n.t("smartkiosk.roles").with_indifferent_access if roles.include?(keyword) roles[keyword] else I18n.t "activerecord.models.#{keyword.singularize}.other" end end |