Module: ActiveElement

Extended by:
Paintbrush
Defined in:
lib/active_element.rb,
lib/active_element/route.rb,
lib/active_element/engine.rb,
lib/active_element/routes.rb,
lib/active_element/version.rb,
lib/active_element/component.rb,
lib/active_element/components.rb,
lib/active_element/field_options.rb,
lib/active_element/components/tab.rb,
lib/active_element/components/form.rb,
lib/active_element/components/json.rb,
lib/active_element/components/tabs.rb,
lib/active_element/components/util.rb,
lib/active_element/rails_component.rb,
lib/active_element/active_menu_link.rb,
lib/active_element/controller_state.rb,
lib/active_element/components/button.rb,
lib/active_element/components/navbar.rb,
lib/active_element/controller_action.rb,
lib/active_element/json_field_schema.rb,
lib/active_element/permissions_check.rb,
lib/active_element/default_controller.rb,
lib/active_element/permissions_report.rb,
lib/active_element/components/util/i18n.rb,
lib/active_element/controller_interface.rb,
lib/active_element/components/item_table.rb,
lib/active_element/pre_render_processors.rb,
lib/active_element/components/text_search.rb,
lib/active_element/components/email_fields.rb,
lib/active_element/components/link_helpers.rb,
lib/active_element/components/phone_fields.rb,
lib/active_element/components/translations.rb,
lib/active_element/components/secret_fields.rb,
lib/active_element/components/util/decorator.rb,
lib/active_element/default_controller/params.rb,
lib/active_element/default_controller/search.rb,
lib/active_element/components/text_search/sql.rb,
lib/active_element/pre_render_processors/json.rb,
lib/active_element/components/collection_table.rb,
lib/active_element/components/page_description.rb,
lib/active_element/components/util/record_path.rb,
lib/active_element/components/util/field_mapping.rb,
lib/active_element/components/util/numeric_field.rb,
lib/active_element/default_controller/controller.rb,
lib/active_element/components/util/record_mapping.rb,
lib/active_element/default_controller/json_params.rb,
lib/active_element/components/text_search/component.rb,
app/controllers/active_element/application_controller.rb,
lib/active_element/components/util/form_field_mapping.rb,
lib/active_element/components/util/form_value_mapping.rb,
lib/active_element/components/util/association_mapping.rb,
lib/active_element/components/text_search/authorization.rb,
lib/active_element/components/util/default_display_value.rb,
lib/active_element/components/util/display_value_mapping.rb,
app/controllers/concerns/active_element/default_controller_actions.rb

Overview

ActiveElement API Admin UI template and menu system.

Defined Under Namespace

Modules: Components, DefaultController, DefaultControllerActions, PreRenderProcessors Classes: ActiveMenuLink, ApplicationController, Component, ControllerAction, ControllerInterface, ControllerState, Engine, Error, FieldOptions, JsonFieldSchema, PermissionsCheck, PermissionsReport, RailsComponent, Route, Routes, UnknownAttributeError, UnprotectedRouteError

Constant Summary collapse

VERSION =
'0.0.31'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.application_name=(value) ⇒ Object (writeonly)

Sets the attribute application_name

Parameters:

  • value

    the value to set the attribute application_name to.



37
38
39
# File 'lib/active_element.rb', line 37

def application_name=(value)
  @application_name = value
end

Returns the value of attribute navbar_items.



38
39
40
# File 'lib/active_element.rb', line 38

def navbar_items
  @navbar_items
end

Class Method Details

.application_titleObject



42
43
44
# File 'lib/active_element.rb', line 42

def application_title
  @application_name || RailsComponent.new(Rails).application_name.titleize
end

.eager_load(resource) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/active_element.rb', line 82

def eager_load(resource)
  return if @eager_loaded[resource]

  suffix = resource == :controllers ? '_controller' : nil
  Rails.root.join("app/#{resource}").glob("**/*#{suffix}.rb").each { |path| require path }
  @eager_loaded[resource] = true unless Rails.env.development?
end

.eager_load_controllersObject



78
79
80
# File 'lib/active_element.rb', line 78

def eager_load_controllers
  eager_load(:controllers)
end

.eager_load_modelsObject



74
75
76
# File 'lib/active_element.rb', line 74

def eager_load_models
  eager_load(:models)
end

.element_idObject



90
91
92
# File 'lib/active_element.rb', line 90

def element_id
  "active-element-#{SecureRandom.uuid}"
end

.json_pretty_print(json) ⇒ Object



54
55
56
# File 'lib/active_element.rb', line 54

def json_pretty_print(json)
  Components::Util.json_pretty_print(json)
end

.log_tagObject



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

def log_tag
  paintbrush { cyan "[#{blue 'ActiveElement'}]" }
end

.silence_logging?Boolean

Returns:

  • (Boolean)


67
68
69
70
71
72
# File 'lib/active_element.rb', line 67

def silence_logging?
  return true unless Rails.env.development? || Rails.env.test?
  return true unless ENV.key?('ACTIVE_ELEMENT_DEBUG')

  false
end

.warning(message) ⇒ Object



46
47
48
# File 'lib/active_element.rb', line 46

def warning(message)
  warn "#{log_tag} #{paintbrush { yellow(message) }}"
end

.with_silenced_logging(&block) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/active_element.rb', line 58

def with_silenced_logging(&block)
  return block.call unless silence_logging?

  ActiveSupport::Notifications.unsubscribe 'render_template.action_view'
  ActiveSupport::Notifications.unsubscribe 'render_partial.action_view'

  block.call
end