class Simpleadmin::Adapters::Base
Base
class to provide a unified interface for each adapter
@since 1.0.0
Attributes
database_credentials[R]
Public Class Methods
new(database_credentials:)
click to toggle source
# File lib/simpleadmin/adapters/base.rb, line 11 def initialize(database_credentials:) @database_credentials = database_credentials end
Public Instance Methods
resources(*_args)
click to toggle source
# File lib/simpleadmin/adapters/base.rb, line 23 def resources(*_args) raise NotImplementedError, 'Please follow the unified interface, add method #resources' end
table_columns(*_args)
click to toggle source
# File lib/simpleadmin/adapters/base.rb, line 19 def table_columns(*_args) raise NotImplementedError, 'Please follow the unified interface, add method #table_columns' end
tables()
click to toggle source
# File lib/simpleadmin/adapters/base.rb, line 15 def tables raise NotImplementedError, 'Please follow the unified interface, add method #tables' end
Private Instance Methods
model_class_by_table_name(name)
click to toggle source
# File lib/simpleadmin/adapters/base.rb, line 39 def model_class_by_table_name(name) name.classify.safe_constantize end
order_asc?(order)
click to toggle source
# File lib/simpleadmin/adapters/base.rb, line 31 def order_asc?(order) order == 'asc' end
order_desc?(order)
click to toggle source
# File lib/simpleadmin/adapters/base.rb, line 35 def order_desc?(order) order == 'desc' end
table_names()
click to toggle source
# File lib/simpleadmin/adapters/base.rb, line 43 def table_names return client.tables if Config.allowed_tables.include?(:all) Config.allowed_tables end