Class: Koi::Config
- Inherits:
-
Object
- Object
- Koi::Config
- Defined in:
- lib/koi/config.rb
Instance Attribute Summary collapse
-
#action_text_editor ⇒ Object
Returns the value of attribute action_text_editor.
-
#admin_javascript_entry_point ⇒ Object
Returns the value of attribute admin_javascript_entry_point.
-
#admin_name ⇒ Object
Returns the value of attribute admin_name.
-
#admin_stylesheet ⇒ Object
Returns the value of attribute admin_stylesheet.
-
#authenticate_local_admins ⇒ Object
Returns the value of attribute authenticate_local_admins.
-
#document_mime_types ⇒ Object
Returns the value of attribute document_mime_types.
-
#document_size_limit ⇒ Object
Returns the value of attribute document_size_limit.
-
#image_mime_types ⇒ Object
Returns the value of attribute image_mime_types.
-
#image_size_limit ⇒ Object
Returns the value of attribute image_size_limit.
-
#resource_name_candidates ⇒ Object
Returns the value of attribute resource_name_candidates.
-
#site_name ⇒ Object
Returns the value of attribute site_name.
Instance Method Summary collapse
-
#identity ⇒ Object
Identity & access settings for OIDC authentication.
- #identity=(options) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#load(app) ⇒ Object
Load config/koi.yml, if present.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/koi/config.rb', line 21 def initialize @action_text_editor = nil @admin_name = "Koi" @authenticate_local_admins = Rails.env.development? @resource_name_candidates = %i[title name] @admin_stylesheet = "admin" @admin_javascript_entry_point = "@katalyst/koi" @document_mime_types = %w[image/png image/gif image/jpeg image/webp application/pdf audio/*].freeze @document_size_limit = 10.megabytes @image_mime_types = %w[image/png image/gif image/jpeg image/webp].freeze @image_size_limit = 10.megabytes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object (private)
rubocop:disable Style/MissingRespondToMissing
58 59 60 61 62 |
# File 'lib/koi/config.rb', line 58 def method_missing(name, *) # rubocop:disable Style/MissingRespondToMissing return super unless name.to_s.end_with?("=") raise ArgumentError, "Unknown Koi config setting: #{name.to_s.chomp('=')}" end |
Instance Attribute Details
#action_text_editor ⇒ Object
Returns the value of attribute action_text_editor.
9 10 11 |
# File 'lib/koi/config.rb', line 9 def action_text_editor @action_text_editor end |
#admin_javascript_entry_point ⇒ Object
Returns the value of attribute admin_javascript_entry_point.
9 10 11 |
# File 'lib/koi/config.rb', line 9 def admin_javascript_entry_point @admin_javascript_entry_point end |
#admin_name ⇒ Object
Returns the value of attribute admin_name.
9 10 11 |
# File 'lib/koi/config.rb', line 9 def admin_name @admin_name end |
#admin_stylesheet ⇒ Object
Returns the value of attribute admin_stylesheet.
9 10 11 |
# File 'lib/koi/config.rb', line 9 def admin_stylesheet @admin_stylesheet end |
#authenticate_local_admins ⇒ Object
Returns the value of attribute authenticate_local_admins.
9 10 11 |
# File 'lib/koi/config.rb', line 9 def authenticate_local_admins @authenticate_local_admins end |
#document_mime_types ⇒ Object
Returns the value of attribute document_mime_types.
9 10 11 |
# File 'lib/koi/config.rb', line 9 def document_mime_types @document_mime_types end |
#document_size_limit ⇒ Object
Returns the value of attribute document_size_limit.
9 10 11 |
# File 'lib/koi/config.rb', line 9 def document_size_limit @document_size_limit end |
#image_mime_types ⇒ Object
Returns the value of attribute image_mime_types.
9 10 11 |
# File 'lib/koi/config.rb', line 9 def image_mime_types @image_mime_types end |
#image_size_limit ⇒ Object
Returns the value of attribute image_size_limit.
9 10 11 |
# File 'lib/koi/config.rb', line 9 def image_size_limit @image_size_limit end |
#resource_name_candidates ⇒ Object
Returns the value of attribute resource_name_candidates.
9 10 11 |
# File 'lib/koi/config.rb', line 9 def resource_name_candidates @resource_name_candidates end |
#site_name ⇒ Object
Returns the value of attribute site_name.
9 10 11 |
# File 'lib/koi/config.rb', line 9 def site_name @site_name end |
Instance Method Details
#identity ⇒ Object
Identity & access settings for OIDC authentication.
35 36 37 |
# File 'lib/koi/config.rb', line 35 def identity @identity ||= ActiveSupport::OrderedOptions.new.merge!(providers: {}, members: {}) end |
#identity=(options) ⇒ Object
39 40 41 |
# File 'lib/koi/config.rb', line 39 def identity=() identity.deep_merge!(.to_h) end |
#load(app) ⇒ Object
Load config/koi.yml, if present
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/koi/config.rb', line 44 def load(app) app.config_for(:koi).each do |attribute, value| public_send("#{attribute}=", value) end self rescue RuntimeError => e raise unless e..start_with?("Could not load configuration") self end |