Class: Jav::Configuration
- Inherits:
-
Object
- Object
- Jav::Configuration
- Includes:
- ResourceConfiguration
- Defined in:
- lib/jav/configuration.rb,
lib/jav/configuration/resource_configuration.rb
Defined Under Namespace
Modules: ResourceConfiguration Classes: Branding
Instance Attribute Summary collapse
- #app_name ⇒ Object
-
#authenticate ⇒ Object
Returns the value of attribute authenticate.
-
#authorization_client ⇒ Object
Returns the value of attribute authorization_client.
-
#authorization_methods ⇒ Object
Returns the value of attribute authorization_methods.
- #branding ⇒ Object
-
#buttons_on_form_footers ⇒ Object
Returns the value of attribute buttons_on_form_footers.
-
#cache_resource_filters ⇒ Object
Returns the value of attribute cache_resource_filters.
-
#cache_resources_on_index_view ⇒ Object
Returns the value of attribute cache_resources_on_index_view.
- #cache_store ⇒ Object
-
#context ⇒ Object
Returns the value of attribute context.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#current_user_resource_name ⇒ Object
Returns the value of attribute current_user_resource_name.
-
#default_view_type ⇒ Object
Returns the value of attribute default_view_type.
-
#disabled_features ⇒ Object
Returns the value of attribute disabled_features.
-
#display_breadcrumbs ⇒ Object
Returns the value of attribute display_breadcrumbs.
-
#display_license_request_timeout_error ⇒ Object
Returns the value of attribute display_license_request_timeout_error.
-
#field_wrapper_layout ⇒ Object
Returns the value of attribute field_wrapper_layout.
-
#full_width_container ⇒ Object
Returns the value of attribute full_width_container.
-
#full_width_index_view ⇒ Object
Returns the value of attribute full_width_index_view.
-
#hide_layout_when_printing ⇒ Object
Returns the value of attribute hide_layout_when_printing.
-
#home_path ⇒ Object
Returns the value of attribute home_path.
-
#id_links_to_resource ⇒ Object
Returns the value of attribute id_links_to_resource.
-
#initial_breadcrumbs ⇒ Object
Returns the value of attribute initial_breadcrumbs.
-
#license ⇒ Object
Returns the value of attribute license.
-
#license_key ⇒ Object
Returns the value of attribute license_key.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#main_menu ⇒ Object
Returns the value of attribute main_menu.
-
#model_resource_mapping ⇒ Object
Returns the value of attribute model_resource_mapping.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#per_page_steps ⇒ Object
Returns the value of attribute per_page_steps.
-
#prefix_path ⇒ Object
Returns the value of attribute prefix_path.
-
#profile_menu ⇒ Object
Returns the value of attribute profile_menu.
-
#raise_error_on_missing_policy ⇒ Object
Returns the value of attribute raise_error_on_missing_policy.
-
#resource_default_view ⇒ Object
Returns the value of attribute resource_default_view.
-
#resources ⇒ Object
Returns the value of attribute resources.
- #root_path ⇒ Object
-
#search_debounce ⇒ Object
Returns the value of attribute search_debounce.
-
#sign_out_path_name ⇒ Object
Returns the value of attribute sign_out_path_name.
-
#tabs_style ⇒ Object
Returns the value of attribute tabs_style.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
-
#via_per_page ⇒ Object
Returns the value of attribute via_per_page.
-
#view_component_path ⇒ Object
Returns the value of attribute view_component_path.
Instance Method Summary collapse
- #authenticate_with(&block) ⇒ Object
-
#computed_cache_store ⇒ Object
When not in production or test we'll just use the MemoryStore which is good enough.
- #current_user_method(&block) ⇒ Object
- #current_user_method=(method) ⇒ Object
- #feature_enabled?(feature) ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #namespace ⇒ Object
- #set_context(&block) ⇒ Object
- #set_initial_breadcrumbs(&block) ⇒ Object
Methods included from ResourceConfiguration
#resource_controls_on_the_left?, #resource_controls_on_the_right?, #resource_controls_placement, #resource_controls_placement=
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 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 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/jav/configuration.rb', line 8 def initialize @root_path = "/jav" @app_name = ::Rails.application.class.to_s.split("::").first.underscore.humanize(keep_id_suffix: true) @timezone = "UTC" @per_page = 24 @per_page_steps = [12, 24, 48, 72] @via_per_page = 8 @locale = nil @currency = "USD" @default_view_type = :table @license = "community" @license_key = nil @current_user = proc {} @authenticate = proc {} @authorization_methods = { index: "index?", show: "show?", edit: "edit?", new: "new?", update: "update?", create: "create?", destroy: "destroy?" } @id_links_to_resource = false @full_width_container = false @full_width_index_view = false @cache_resources_on_index_view = Jav::PACKED @cache_resource_filters = false @context = proc {} @initial_breadcrumbs = proc { I18n.t("jav.home").humanize, jav.root_path } @display_breadcrumbs = true @hide_layout_when_printing = false @home_path = nil @search_debounce = 300 @view_component_path = "app/components" @display_license_request_timeout_error = true @current_user_resource_name = "user" @raise_error_on_missing_policy = false @disabled_features = [] @buttons_on_form_footers = false @main_menu = nil @profile_menu = nil @model_resource_mapping = {} @tabs_style = :tabs @resource_default_view = :show @authorization_client = :pundit @field_wrapper_layout = :inline @resources = nil @prefix_path = nil @cache_store = computed_cache_store end |
Instance Attribute Details
#app_name ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/jav/configuration.rb', line 104 def app_name if @app_name.respond_to? :call Jav::Hosts::BaseHost.new(block: @app_name).handle else @app_name end end |
#authenticate ⇒ Object
Returns the value of attribute authenticate.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def authenticate @authenticate end |
#authorization_client ⇒ Object
Returns the value of attribute authorization_client.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def @authorization_client end |
#authorization_methods ⇒ Object
Returns the value of attribute authorization_methods.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def @authorization_methods end |
#branding ⇒ Object
100 101 102 |
# File 'lib/jav/configuration.rb', line 100 def branding Jav::Configuration::Branding.new(**@branding || {}) end |
#buttons_on_form_footers ⇒ Object
Returns the value of attribute buttons_on_form_footers.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def @buttons_on_form_footers end |
#cache_resource_filters ⇒ Object
Returns the value of attribute cache_resource_filters.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def cache_resource_filters @cache_resource_filters end |
#cache_resources_on_index_view ⇒ Object
Returns the value of attribute cache_resources_on_index_view.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def cache_resources_on_index_view @cache_resources_on_index_view end |
#cache_store ⇒ Object
112 113 114 115 116 117 |
# File 'lib/jav/configuration.rb', line 112 def cache_store Jav::ExecutionContext.new( target: @cache_store, production_rejected_cache_stores: %w[ActiveSupport::Cache::MemoryStore ActiveSupport::Cache::NullStore] ).handle end |
#context ⇒ Object
Returns the value of attribute context.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def context @context end |
#currency ⇒ Object
Returns the value of attribute currency.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def currency @currency end |
#current_user ⇒ Object
Returns the value of attribute current_user.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def current_user @current_user end |
#current_user_resource_name ⇒ Object
Returns the value of attribute current_user_resource_name.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def current_user_resource_name @current_user_resource_name end |
#default_view_type ⇒ Object
Returns the value of attribute default_view_type.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def default_view_type @default_view_type end |
#disabled_features ⇒ Object
Returns the value of attribute disabled_features.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def disabled_features @disabled_features end |
#display_breadcrumbs ⇒ Object
Returns the value of attribute display_breadcrumbs.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def @display_breadcrumbs end |
#display_license_request_timeout_error ⇒ Object
Returns the value of attribute display_license_request_timeout_error.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def display_license_request_timeout_error @display_license_request_timeout_error end |
#field_wrapper_layout ⇒ Object
Returns the value of attribute field_wrapper_layout.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def field_wrapper_layout @field_wrapper_layout end |
#full_width_container ⇒ Object
Returns the value of attribute full_width_container.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def full_width_container @full_width_container end |
#full_width_index_view ⇒ Object
Returns the value of attribute full_width_index_view.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def full_width_index_view @full_width_index_view end |
#hide_layout_when_printing ⇒ Object
Returns the value of attribute hide_layout_when_printing.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def hide_layout_when_printing @hide_layout_when_printing end |
#home_path ⇒ Object
Returns the value of attribute home_path.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def home_path @home_path end |
#id_links_to_resource ⇒ Object
Returns the value of attribute id_links_to_resource.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def id_links_to_resource @id_links_to_resource end |
#initial_breadcrumbs ⇒ Object
Returns the value of attribute initial_breadcrumbs.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def @initial_breadcrumbs end |
#license ⇒ Object
Returns the value of attribute license.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def license @license end |
#license_key ⇒ Object
Returns the value of attribute license_key.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def license_key @license_key end |
#locale ⇒ Object
Returns the value of attribute locale.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def locale @locale end |
#main_menu ⇒ Object
Returns the value of attribute main_menu.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def @main_menu end |
#model_resource_mapping ⇒ Object
Returns the value of attribute model_resource_mapping.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def model_resource_mapping @model_resource_mapping end |
#per_page ⇒ Object
Returns the value of attribute per_page.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def per_page @per_page end |
#per_page_steps ⇒ Object
Returns the value of attribute per_page_steps.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def per_page_steps @per_page_steps end |
#prefix_path ⇒ Object
Returns the value of attribute prefix_path.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def prefix_path @prefix_path end |
#profile_menu ⇒ Object
Returns the value of attribute profile_menu.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def @profile_menu end |
#raise_error_on_missing_policy ⇒ Object
Returns the value of attribute raise_error_on_missing_policy.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def raise_error_on_missing_policy @raise_error_on_missing_policy end |
#resource_default_view ⇒ Object
Returns the value of attribute resource_default_view.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def resource_default_view @resource_default_view end |
#resources ⇒ Object
Returns the value of attribute resources.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def resources @resources end |
#root_path ⇒ Object
90 91 92 93 94 |
# File 'lib/jav/configuration.rb', line 90 def root_path return "" if @root_path == "/" @root_path end |
#search_debounce ⇒ Object
Returns the value of attribute search_debounce.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def search_debounce @search_debounce end |
#sign_out_path_name ⇒ Object
Returns the value of attribute sign_out_path_name.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def sign_out_path_name @sign_out_path_name end |
#tabs_style ⇒ Object
Returns the value of attribute tabs_style.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def tabs_style @tabs_style end |
#timezone ⇒ Object
Returns the value of attribute timezone.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def timezone @timezone end |
#via_per_page ⇒ Object
Returns the value of attribute via_per_page.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def via_per_page @via_per_page end |
#view_component_path ⇒ Object
Returns the value of attribute view_component_path.
6 7 8 |
# File 'lib/jav/configuration.rb', line 6 def view_component_path @view_component_path end |
Instance Method Details
#authenticate_with(&block) ⇒ Object
70 71 72 |
# File 'lib/jav/configuration.rb', line 70 def authenticate_with(&block) @authenticate = block if block.present? end |
#computed_cache_store ⇒ Object
When not in production or test we'll just use the MemoryStore which is good enough. When running in production we'll use Rails.cache if it's not ActiveSupport::Cache::MemoryStore or ActiveSupport::Cache::NullStore. If it's one of rejected cache stores, we'll use the FileStore. We decided against the MemoryStore in production because it will not be shared between multiple processes (when using Puma).
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/jav/configuration.rb', line 123 def computed_cache_store lambda { if Rails.env.production? if Rails.cache.class.to_s.in?(production_rejected_cache_stores) ActiveSupport::Cache.lookup_store(:file_store, Rails.root.join("tmp/cache")) else Rails.cache end elsif Rails.env.test? Rails.cache else ActiveSupport::Cache.lookup_store(:memory_store) end } end |
#current_user_method(&block) ⇒ Object
62 63 64 |
# File 'lib/jav/configuration.rb', line 62 def current_user_method(&block) @current_user = block if block.present? end |
#current_user_method=(method) ⇒ Object
66 67 68 |
# File 'lib/jav/configuration.rb', line 66 def current_user_method=(method) @current_user = method if method.present? end |
#feature_enabled?(feature) ⇒ Boolean
96 97 98 |
# File 'lib/jav/configuration.rb', line 96 def feature_enabled?(feature) @disabled_features.map(&:to_sym).exclude?(feature.to_sym) end |
#namespace ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/jav/configuration.rb', line 82 def namespace if Jav.configuration.root_path.present? Jav.configuration.root_path.delete "/" else root_path.delete "/" end end |
#set_context(&block) ⇒ Object
74 75 76 |
# File 'lib/jav/configuration.rb', line 74 def set_context(&block) @context = block if block.present? end |
#set_initial_breadcrumbs(&block) ⇒ Object
78 79 80 |
# File 'lib/jav/configuration.rb', line 78 def (&block) @initial_breadcrumbs = block if block.present? end |