lib/olivander/application_context.rb in five-two-nw-olivander-0.2.0.0 vs lib/olivander/application_context.rb in five-two-nw-olivander-0.2.0.1
- old
+ new
@@ -3,10 +3,15 @@
attr_accessor :name, :logo, :company, :menu_items, :route_builder, :sign_out_path, :sidebar_background_class
def self.default
ctx = ApplicationContext.new
ctx.company.name = 'Company Name'
+ begin
+ ctx.route_builder = RouteBuilder.new
+ rescue
+ ctx.route_builder = OpenStruct.new(resources: [])
+ end
ctx
end
def initialize(name: 'Application Name', logo: Logo.new, company: Company.new, sign_out_path: '/sign_out', menu_items: [])
self.name = name
@@ -47,8 +52,17 @@
def initialize(name: nil, url: nil)
self.url = url
self.name = name
end
+ end
+ end
+
+ class CurrentContext < ActiveSupport::CurrentAttributes
+ attribute :application_context
+ attribute :user, :ability
+
+ def application_context
+ @application_context ||= ::Olivander::ApplicationContext.default
end
end
end