class SharkOnLambda::Application
Attributes
routes[R]
Public Class Methods
config()
click to toggle source
# File lib/shark_on_lambda/application.rb, line 10 def config @config ||= Configuration.new end
inherited(subclass)
click to toggle source
Calls superclass method
# File lib/shark_on_lambda/application.rb, line 14 def inherited(subclass) super SharkOnLambda.application = subclass.new end
new()
click to toggle source
# File lib/shark_on_lambda/application.rb, line 21 def initialize register_jsonapi_rendering initialize_router end
Public Instance Methods
call(env)
click to toggle source
# File lib/shark_on_lambda/application.rb, line 26 def call(env) dup.call!(env) end
call!(env)
click to toggle source
# File lib/shark_on_lambda/application.rb, line 30 def call!(env) middleware_stack = middleware.build(routes) middleware_stack.call(env) end
config()
click to toggle source
# File lib/shark_on_lambda/application.rb, line 35 def config self.class.config end
config_for(name, env: SharkOnLambda.env)
click to toggle source
# File lib/shark_on_lambda/application.rb, line 39 def config_for(name, env: SharkOnLambda.env) config = load_config_file(name, env: env, fail_with_exception: true) config.deep_merge(load_config_file("#{name}.local", env: env)) end
initialize!()
click to toggle source
# File lib/shark_on_lambda/application.rb, line 44 def initialize! load_routes run_initializers end
Private Instance Methods
initialize_router()
click to toggle source
# File lib/shark_on_lambda/application.rb, line 51 def initialize_router router_config = ActionDispatch::Routing::RouteSet::Config.new(nil, true) @routes = ActionDispatch::Routing::RouteSet.new_with_config(router_config) end
load_config_file(name, env:, fail_with_exception: false)
click to toggle source
# File lib/shark_on_lambda/application.rb, line 56 def load_config_file(name, env:, fail_with_exception: false) filename = "#{name}.yml" config_file = SharkOnLambda.root.join('config', filename) unless config_file.exist? return {} unless fail_with_exception raise ArgumentError, "Could not load configuration. No such file - #{config_file}" end erb_parsed_config = ERB.new(config_file.read).result config = YAML.safe_load(erb_parsed_config, [], [], true, filename) || {} config.fetch(env, {}).with_indifferent_access end
load_routes()
click to toggle source
# File lib/shark_on_lambda/application.rb, line 71 def load_routes routes_path = SharkOnLambda.root.join('config', 'routes.rb').to_s load routes_path if File.exist?(routes_path) end
register_jsonapi_rendering()
click to toggle source
# File lib/shark_on_lambda/application.rb, line 76 def register_jsonapi_rendering ::Mime::Type.register('application/vnd.api+json', :jsonapi) ::ActionDispatch::Request.parameter_parsers[:jsonapi] = ::ActionDispatch::Request.parameter_parsers[:json].dup end
run_initializers()
click to toggle source
# File lib/shark_on_lambda/application.rb, line 82 def run_initializers initializers_folder = SharkOnLambda.root.join('config', 'initializers') Dir.glob(initializers_folder.join('*.rb')).each { |path| load path } end