Module: Motor

Defined in:
lib/motor.rb,
lib/motor/tags.rb,
lib/motor/admin.rb,
lib/motor/forms.rb,
lib/motor/notes.rb,
lib/motor/slack.rb,
lib/motor/alerts.rb,
lib/motor/assets.rb,
lib/motor/configs.rb,
lib/motor/queries.rb,
lib/motor/railtie.rb,
lib/motor/version.rb,
lib/motor/api_query.rb,
lib/motor/resources.rb,
app/models/motor/tag.rb,
lib/motor/dashboards.rb,
lib/motor/notes/tags.rb,
app/models/motor/form.rb,
app/models/motor/note.rb,
lib/motor/api_configs.rb,
app/models/motor/alert.rb,
app/models/motor/audit.rb,
app/models/motor/query.rb,
lib/motor/build_schema.rb,
lib/motor/cancan_utils.rb,
lib/motor/slack/client.rb,
app/models/motor/config.rb,
lib/motor/notes/persist.rb,
lib/motor/api_query/sort.rb,
lib/motor/net_http_utils.rb,
app/models/motor/note_tag.rb,
app/models/motor/reminder.rb,
app/models/motor/resource.rb,
lib/motor/hash_serializer.rb,
app/models/motor/dashboard.rb,
lib/motor/alerts/scheduler.rb,
lib/motor/api_query/filter.rb,
lib/motor/api_query/search.rb,
app/models/motor/alert_lock.rb,
app/models/motor/api_config.rb,
lib/motor/forms/persistance.rb,
lib/motor/queries/run_query.rb,
lib/motor/alerts/persistance.rb,
lib/motor/api_query/paginate.rb,
lib/motor/build_schema/utils.rb,
app/models/motor/note_tag_tag.rb,
app/models/motor/notification.rb,
app/models/motor/taggable_tag.rb,
lib/motor/active_record_utils.rb,
lib/motor/alerts/slack_sender.rb,
lib/motor/queries/persistance.rb,
app/jobs/motor/application_job.rb,
lib/generators/motor/migration.rb,
lib/motor/api_query/build_json.rb,
lib/motor/api_query/build_meta.rb,
app/mailers/motor/alerts_mailer.rb,
lib/motor/api_query/apply_scope.rb,
lib/motor/build_schema/defaults.rb,
lib/motor/configs/write_to_file.rb,
lib/motor/notes/notify_mentions.rb,
lib/motor/notes/notify_reminder.rb,
app/channels/motor/notes_channel.rb,
app/jobs/motor/alert_sending_job.rb,
lib/motor/build_schema/find_icon.rb,
lib/motor/configs/sync_from_file.rb,
lib/motor/configs/sync_from_hash.rb,
lib/motor/dashboards/persistance.rb,
lib/motor/configs/load_from_cache.rb,
lib/motor/configs/sync_middleware.rb,
app/jobs/motor/notify_reminder_job.rb,
lib/motor/configs/build_ui_app_tag.rb,
lib/motor/configs/sync_with_remote.rb,
app/controllers/motor/ui_controller.rb,
app/models/motor/application_record.rb,
lib/motor/active_record_utils/types.rb,
lib/motor/notes/reminders_scheduler.rb,
lib/motor/resources/persist_configs.rb,
app/mailers/motor/application_mailer.rb,
lib/motor/cancan_utils/ability_patch.rb,
lib/motor/configs/build_configs_hash.rb,
app/controllers/motor/data_controller.rb,
app/controllers/motor/tags_controller.rb,
lib/motor/build_schema/reorder_schema.rb,
lib/motor/cancan_utils/can_manage_all.rb,
lib/motor/queries/render_sql_template.rb,
app/controllers/motor/forms_controller.rb,
app/controllers/motor/icons_controller.rb,
app/controllers/motor/notes_controller.rb,
app/mailers/motor/notifications_mailer.rb,
lib/generators/motor/install_generator.rb,
lib/generators/motor/upgrade_generator.rb,
lib/motor/build_schema/load_from_rails.rb,
app/controllers/motor/alerts_controller.rb,
app/controllers/motor/assets_controller.rb,
app/controllers/motor/audits_controller.rb,
app/controllers/motor/schema_controller.rb,
app/jobs/motor/notify_note_mentions_job.rb,
lib/motor/alerts/scheduled_alerts_cache.rb,
lib/motor/queries/postgresql_exec_query.rb,
app/channels/motor/notifications_channel.rb,
app/controllers/motor/configs_controller.rb,
app/controllers/motor/queries_controller.rb,
lib/motor/build_schema/apply_permissions.rb,
app/controllers/motor/api_base_controller.rb,
app/controllers/motor/sessions_controller.rb,
app/controllers/motor/note_tags_controller.rb,
app/controllers/motor/reminders_controller.rb,
app/controllers/motor/resources_controller.rb,
lib/motor/build_schema/find_display_column.rb,
lib/motor/resources/fetch_configured_model.rb,
app/controllers/motor/dashboards_controller.rb,
lib/motor/active_record_utils/fetch_methods.rb,
lib/motor/build_schema/merge_schema_configs.rb,
app/channels/motor/application_cable/channel.rb,
app/controllers/motor/api_configs_controller.rb,
app/controllers/motor/application_controller.rb,
app/controllers/motor/auth_tokens_controller.rb,
app/controllers/motor/run_queries_controller.rb,
app/controllers/motor/send_alerts_controller.rb,
lib/generators/motor/install_notes_generator.rb,
lib/motor/resources/custom_sql_columns_cache.rb,
app/controllers/concerns/motor/wrap_io_params.rb,
app/controllers/concerns/motor/current_ability.rb,
app/controllers/motor/notifications_controller.rb,
lib/motor/build_schema/find_searchable_columns.rb,
app/channels/motor/application_cable/connection.rb,
app/controllers/motor/resource_methods_controller.rb,
app/controllers/motor/run_api_requests_controller.rb,
lib/motor/build_schema/adjust_devise_model_schema.rb,
app/controllers/concerns/motor/current_user_method.rb,
app/controllers/motor/slack_conversations_controller.rb,
app/controllers/motor/run_graphql_requests_controller.rb,
lib/motor/active_record_utils/defined_scopes_extension.rb,
app/controllers/motor/users_for_autocomplete_controller.rb,
lib/motor/active_record_utils/active_storage_blob_patch.rb,
lib/motor/build_schema/active_storage_attachment_schema.rb,
app/controllers/motor/resource_default_queries_controller.rb,
app/controllers/motor/active_storage_attachments_controller.rb,
lib/motor/active_record_utils/active_storage_links_extension.rb,
app/controllers/concerns/motor/load_and_authorize_dynamic_resource.rb

Defined Under Namespace

Modules: ActiveRecordUtils, Alerts, ApiConfigs, ApiQuery, ApplicationCable, Assets, BuildSchema, CancanUtils, Configs, CurrentAbility, CurrentUserMethod, Dashboards, DatabaseClasses, FindIcon, Forms, Generators, LoadAndAuthorizeDynamicResource, NetHttpUtils, Notes, Queries, ReorderSchema, Resources, Slack, Tags, WrapIoParams Classes: ActiveStorageAttachmentsController, Admin, Alert, AlertLock, AlertSendingJob, AlertsController, AlertsMailer, ApiBaseController, ApiConfig, ApiConfigsController, ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, AssetsController, Audit, AuditsController, AuthTokensController, Config, ConfigsController, Dashboard, DashboardsController, DataController, DummyChannel, Form, FormsController, HashSerializer, IconsController, Note, NoteTag, NoteTagTag, NoteTagsController, NotesChannel, NotesController, Notification, NotificationsChannel, NotificationsController, NotificationsMailer, NotifyNoteMentionsJob, NotifyReminderJob, QueriesController, Query, Railtie, Reminder, RemindersController, Resource, ResourceDefaultQueriesController, ResourceMethodsController, ResourcesController, RunApiRequestsController, RunGraphqlRequestsController, RunQueriesController, SchemaController, SendAlertsController, SessionsController, SlackConversationsController, Tag, TaggableTag, TagsController, UiController, UsersForAutocompleteController

Constant Summary collapse

PATH =
Pathname.new(__dir__)
VERSION =
'0.4.37'

Class Method Summary collapse

Class Method Details

.app_hostObject



50
51
52
53
# File 'lib/motor.rb', line 50

def app_host
  Rails.application.config.action_dispatch.default_url_options&.fetch(:host) ||
    ENV.fetch('HOST', 'example.com')
end

.company_nameObject



55
56
57
# File 'lib/motor.rb', line 55

def company_name
  'Motor Admin'
end

.development?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/motor.rb', line 63

def development?
  ENV['MOTOR_DEVELOPMENT'].present?
end

.reload!Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/motor.rb', line 22

def reload!
  Kernel.silence_warnings do
    Dir[PATH.join('./motor/**/*.rb')].each do |f|
      next if f.ends_with?('alerts/scheduler.rb')
      next if f.ends_with?('notes/reminders_scheduler.rb')
      next if f.ends_with?('alerts/scheduled_alerts_cache.rb')
      next if f.ends_with?('configs/load_from_cache.rb')
      next if f.ends_with?('configs/sync_from_file.rb')
      next if f.ends_with?('resources/custom_sql_columns_cache.rb')

      load f
    end
  end

  true
end

.server?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
46
47
48
# File 'lib/motor.rb', line 39

def server?
  defined?(::Rails::Server) ||
    defined?(::Thin::Server) ||
    defined?(::PhusionPassenger) ||
    (defined?(::Puma) && File.basename($PROGRAM_NAME) == 'puma') ||
    defined?(::Unicorn::HttpServer) ||
    defined?(::Mongrel::HttpServer) ||
    defined?(JRuby::Rack::VERSION) ||
    defined?(::Trinidad::Server)
end

.with_public_access?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/motor.rb', line 59

def with_public_access?
  ENV['MOTOR_PUBLIC_ACCESS'].to_s == 'true'
end