Module: Legion::Data::Helper
- Includes:
- Logging::Helper
- Defined in:
- lib/legion/data/helper.rb
Instance Method Summary collapse
-
#data_adapter ⇒ Object
— Pool / Resource Info —.
-
#data_can_read?(table_name) ⇒ Boolean
— Permission Helpers —.
- #data_can_write?(table_name) ⇒ Boolean
- #data_class ⇒ Object
- #data_connected? ⇒ Boolean
- #data_connection ⇒ Object
- #data_path ⇒ Object
- #data_pool_stats ⇒ Object
- #data_stats ⇒ Object
- #local_data_connected? ⇒ Boolean
- #local_data_connection ⇒ Object
- #local_data_model(table_name) ⇒ Object
- #local_data_stats ⇒ Object
- #models_class ⇒ Object
Methods included from Logging::Helper
Instance Method Details
#data_adapter ⇒ Object
— Pool / Resource Info —
44 45 46 47 48 49 |
# File 'lib/legion/data/helper.rb', line 44 def data_adapter Legion::Data::Connection.adapter rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: :data_adapter) :unknown end |
#data_can_read?(table_name) ⇒ Boolean
— Permission Helpers —
80 81 82 83 84 85 |
# File 'lib/legion/data/helper.rb', line 80 def data_can_read?(table_name) Legion::Data.can_read?(table_name) rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: :data_can_read, table: table_name) false end |
#data_can_write?(table_name) ⇒ Boolean
87 88 89 90 91 92 |
# File 'lib/legion/data/helper.rb', line 87 def data_can_write?(table_name) Legion::Data.can_write?(table_name) rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: :data_can_write, table: table_name) false end |
#data_class ⇒ Object
14 15 16 |
# File 'lib/legion/data/helper.rb', line 14 def data_class @data_class ||= lex_class::Data end |
#data_connected? ⇒ Boolean
22 23 24 |
# File 'lib/legion/data/helper.rb', line 22 def data_connected? defined?(Legion::Settings) && Legion::Settings[:data][:connected] end |
#data_connection ⇒ Object
26 27 28 |
# File 'lib/legion/data/helper.rb', line 26 def data_connection Legion::Data::Connection.sequel end |
#data_path ⇒ Object
10 11 12 |
# File 'lib/legion/data/helper.rb', line 10 def data_path @data_path ||= "#{full_path}/data" end |
#data_pool_stats ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/legion/data/helper.rb', line 51 def data_pool_stats return {} unless data_connected? Legion::Data::Connection.pool_stats rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: :data_pool_stats) {} end |
#data_stats ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/legion/data/helper.rb', line 60 def data_stats return {} unless data_connected? Legion::Data.stats rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: :data_stats) {} end |
#local_data_connected? ⇒ Boolean
30 31 32 |
# File 'lib/legion/data/helper.rb', line 30 def local_data_connected? Legion::Data::Local.connected? end |
#local_data_connection ⇒ Object
34 35 36 |
# File 'lib/legion/data/helper.rb', line 34 def local_data_connection Legion::Data::Local.connection end |
#local_data_model(table_name) ⇒ Object
38 39 40 |
# File 'lib/legion/data/helper.rb', line 38 def local_data_model(table_name) Legion::Data::Local.model(table_name) end |
#local_data_stats ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/legion/data/helper.rb', line 69 def local_data_stats return {} unless local_data_connected? Legion::Data::Local.stats rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: :local_data_stats) {} end |
#models_class ⇒ Object
18 19 20 |
# File 'lib/legion/data/helper.rb', line 18 def models_class @models_class ||= data_class::Model end |