Class: Avo::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/avo/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/avo/configuration.rb', line 32

def initialize
  @root_path = "/avo"
  @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 = "en-US"
  @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 = Avo::PACKED
  @context = proc {}
  @initial_breadcrumbs = proc {
    add_breadcrumb I18n.t("avo.home").humanize, avo.root_path
  }
  @display_breadcrumbs = true
  @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 = []
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



4
5
6
# File 'lib/avo/configuration.rb', line 4

def app_name
  @app_name
end

#authenticateObject

Returns the value of attribute authenticate.



15
16
17
# File 'lib/avo/configuration.rb', line 15

def authenticate
  @authenticate
end

#authorization_methodsObject

Returns the value of attribute authorization_methods.



14
15
16
# File 'lib/avo/configuration.rb', line 14

def authorization_methods
  @authorization_methods
end

#cache_resources_on_index_viewObject

Returns the value of attribute cache_resources_on_index_view.



20
21
22
# File 'lib/avo/configuration.rb', line 20

def cache_resources_on_index_view
  @cache_resources_on_index_view
end

#contextObject

Returns the value of attribute context.



21
22
23
# File 'lib/avo/configuration.rb', line 21

def context
  @context
end

#currencyObject

Returns the value of attribute currency.



10
11
12
# File 'lib/avo/configuration.rb', line 10

def currency
  @currency
end

#current_userObject

Returns the value of attribute current_user.



16
17
18
# File 'lib/avo/configuration.rb', line 16

def current_user
  @current_user
end

#current_user_resource_nameObject

Returns the value of attribute current_user_resource_name.



28
29
30
# File 'lib/avo/configuration.rb', line 28

def current_user_resource_name
  @current_user_resource_name
end

#default_view_typeObject

Returns the value of attribute default_view_type.



11
12
13
# File 'lib/avo/configuration.rb', line 11

def default_view_type
  @default_view_type
end

#disabled_featuresObject

Returns the value of attribute disabled_features.



30
31
32
# File 'lib/avo/configuration.rb', line 30

def disabled_features
  @disabled_features
end

#display_breadcrumbsObject

Returns the value of attribute display_breadcrumbs.



22
23
24
# File 'lib/avo/configuration.rb', line 22

def display_breadcrumbs
  @display_breadcrumbs
end

#display_license_request_timeout_errorObject

Returns the value of attribute display_license_request_timeout_error.



27
28
29
# File 'lib/avo/configuration.rb', line 27

def display_license_request_timeout_error
  @display_license_request_timeout_error
end

#full_width_containerObject

Returns the value of attribute full_width_container.



18
19
20
# File 'lib/avo/configuration.rb', line 18

def full_width_container
  @full_width_container
end

#full_width_index_viewObject

Returns the value of attribute full_width_index_view.



19
20
21
# File 'lib/avo/configuration.rb', line 19

def full_width_index_view
  @full_width_index_view
end

#home_pathObject

Returns the value of attribute home_path.



24
25
26
# File 'lib/avo/configuration.rb', line 24

def home_path
  @home_path
end

Returns the value of attribute id_links_to_resource.



17
18
19
# File 'lib/avo/configuration.rb', line 17

def id_links_to_resource
  @id_links_to_resource
end

#initial_breadcrumbsObject

Returns the value of attribute initial_breadcrumbs.



23
24
25
# File 'lib/avo/configuration.rb', line 23

def initial_breadcrumbs
  @initial_breadcrumbs
end

#licenseObject

Returns the value of attribute license.



12
13
14
# File 'lib/avo/configuration.rb', line 12

def license
  @license
end

#license_keyObject

Returns the value of attribute license_key.



13
14
15
# File 'lib/avo/configuration.rb', line 13

def license_key
  @license_key
end

#localeObject

Returns the value of attribute locale.



9
10
11
# File 'lib/avo/configuration.rb', line 9

def locale
  @locale
end

#per_pageObject

Returns the value of attribute per_page.



6
7
8
# File 'lib/avo/configuration.rb', line 6

def per_page
  @per_page
end

#per_page_stepsObject

Returns the value of attribute per_page_steps.



7
8
9
# File 'lib/avo/configuration.rb', line 7

def per_page_steps
  @per_page_steps
end

#raise_error_on_missing_policyObject

Returns the value of attribute raise_error_on_missing_policy.



29
30
31
# File 'lib/avo/configuration.rb', line 29

def raise_error_on_missing_policy
  @raise_error_on_missing_policy
end

#root_pathObject



111
112
113
114
115
# File 'lib/avo/configuration.rb', line 111

def root_path
  return "" if @root_path === "/"

  @root_path
end

#search_debounceObject

Returns the value of attribute search_debounce.



25
26
27
# File 'lib/avo/configuration.rb', line 25

def search_debounce
  @search_debounce
end

#timezoneObject

Returns the value of attribute timezone.



5
6
7
# File 'lib/avo/configuration.rb', line 5

def timezone
  @timezone
end

#via_per_pageObject

Returns the value of attribute via_per_page.



8
9
10
# File 'lib/avo/configuration.rb', line 8

def via_per_page
  @via_per_page
end

#view_component_pathObject

Returns the value of attribute view_component_path.



26
27
28
# File 'lib/avo/configuration.rb', line 26

def view_component_path
  @view_component_path
end

Instance Method Details

#authenticate_with(&block) ⇒ Object



91
92
93
# File 'lib/avo/configuration.rb', line 91

def authenticate_with(&block)
  @authenticate = block if block.present?
end

#computed_root_pathObject



117
118
119
# File 'lib/avo/configuration.rb', line 117

def computed_root_path
  Avo::App.root_path
end

#current_user_method(&block) ⇒ Object



83
84
85
# File 'lib/avo/configuration.rb', line 83

def current_user_method(&block)
  @current_user = block if block.present?
end

#current_user_method=(method) ⇒ Object



87
88
89
# File 'lib/avo/configuration.rb', line 87

def current_user_method=(method)
  @current_user = method if method.present?
end

#feature_enabled?(feature) ⇒ Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/avo/configuration.rb', line 121

def feature_enabled?(feature)
  !@disabled_features.map(&:to_sym).include?(feature.to_sym)
end

#language_codeObject



77
78
79
80
81
# File 'lib/avo/configuration.rb', line 77

def language_code
  locale_tag.language.code
rescue
  "en"
end

#locale_tagObject



73
74
75
# File 'lib/avo/configuration.rb', line 73

def locale_tag
  ::ISO::Tag.new(locale)
end

#namespaceObject



103
104
105
106
107
108
109
# File 'lib/avo/configuration.rb', line 103

def namespace
  if computed_root_path.present?
    computed_root_path.delete "/"
  else
    root_path.delete "/"
  end
end

#set_context(&block) ⇒ Object



95
96
97
# File 'lib/avo/configuration.rb', line 95

def set_context(&block)
  @context = block if block.present?
end

#set_initial_breadcrumbs(&block) ⇒ Object



99
100
101
# File 'lib/avo/configuration.rb', line 99

def set_initial_breadcrumbs(&block)
  @initial_breadcrumbs = block if block.present?
end