module MnoEnterprise
Constants
- VERSION
Public Class Methods
configure() { |self| ... }
click to toggle source
Default way to setup MnoEnterprise
. Run rails generate mno-enterprise:install to create a fresh initializer with all configuration values.
# File lib/mno_enterprise/core.rb, line 272 def self.configure yield self self.configure_styleguide self.configure_api # Mail config # We can't use the setter before MailClient is loaded self.mail_adapter = self.mail_adapter end
intercom_enabled?()
click to toggle source
Define if Intercom is enabled. Only if the gem intercom is present
# File lib/mno_enterprise/core.rb, line 229 def self.intercom_enabled? defined?(::Intercom) && ((intercom_app_id && intercom_api_key) || intercom_token) end
jwt(payload)
click to toggle source
Create a JSON web token with the provided payload E.g.: MnoEnterprise.jwt
({ user_id: 'usr-427431' })
# File lib/mno_enterprise/core.rb, line 284 def self.jwt(payload) secret = "#{self.tenant_id}:#{self.tenant_key}" iat = Time.now.utc.to_i JWT.encode(payload.merge( iss: MnoEnterprise.tenant_id, iat: iat, jit: Digest::MD5.hexdigest("#{secret}:#{iat}") ), secret) end
mail_adapter=(adapter)
click to toggle source
# File lib/mno_enterprise/core.rb, line 182 def self.mail_adapter=(adapter) @@mail_adapter = adapter MnoEnterprise::MailClient.adapter = self.mail_adapter end
mandrill_key()
click to toggle source
mandrill_key=(mandrill_key)
click to toggle source
# File lib/mno_enterprise/core.rb, line 173 def self.mandrill_key=(mandrill_key) warn "[DEPRECATION] `mandrill_key` is deprecated. Use `ENV['MANDRILL_API_KEY']`." @@mandrill_key = mandrill_key end
style()
click to toggle source
Always reload style in development
# File lib/mno_enterprise/core.rb, line 263 def self.style self.configure_styleguide if Rails.env.development? @@style end
Private Class Methods
api_options()
click to toggle source
Return the options to use in the setup of the API
# File lib/mno_enterprise/core.rb, line 297 def self.api_options api_host = @@mno_api_private_host || @@mno_api_host { url: "#{URI.join(api_host,@@mno_api_root_path).to_s}", send_only_modified_attributes: true } end
configure_api()
click to toggle source
Configure the Her
for Maestrano Enterprise API V1
# File lib/mno_enterprise/core.rb, line 321 def self.configure_api # Configure HER for Maestrano Enterprise Endpoints @@mnoe_api_v1 = Her::API.new @@mnoe_api_v1.setup self.api_options do |c| # Request c.use Faraday::Request::BasicAuthentication, @@tenant_id, @@tenant_key # c.use Faraday::Request::UrlEncoded c.request :json # Instrumentation in development c.use :instrumentation if Rails.env.development? # Response c.use Her::Middleware::MnoeApiV1ParseJson # Adapter c.use Faraday::Adapter::NetHttpNoProxy # Error Handling c.use Her::Middleware::MnoeRaiseError end end
configure_styleguide()
click to toggle source
Load the provided styleguide hash into nested structure or load a default one
# File lib/mno_enterprise/core.rb, line 306 def self.configure_styleguide # Load default gem configuration hash = YAML.load(File.read(File.join(MnoEnterprise::Engine.root,'config','styleguide.yml'))) # Load default app styleguide, unless explicitly specified default_path = File.join(Rails.root,'config','mno_enterprise_styleguide.yml') if !@@styleguide && File.exists?(default_path) @@styleguide = YAML.load(File.read(default_path)) end @@styleguide.is_a?(Hash) && hash.deep_merge!(@@styleguide) @@style = DeepStruct.wrap(hash) end