Class: Praxis::Application
- Inherits:
-
Object
- Object
- Praxis::Application
- Includes:
- Singleton
- Defined in:
- lib/praxis/application.rb
Instance Attribute Summary collapse
-
#bootloader ⇒ Object
Returns the value of attribute bootloader.
-
#controllers ⇒ Object
readonly
Returns the value of attribute controllers.
-
#file_layout ⇒ Object
Returns the value of attribute file_layout.
-
#loaded_files ⇒ Object
Returns the value of attribute loaded_files.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#plugins ⇒ Object
Returns the value of attribute plugins.
-
#resource_definitions ⇒ Object
readonly
Returns the value of attribute resource_definitions.
-
#root ⇒ Object
Returns the value of attribute root.
-
#router ⇒ Object
readonly
Returns the value of attribute router.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
- #config(key = nil, type = Attributor::Struct, **opts, &block) ⇒ Object
- #config=(config) ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #layout(&block) ⇒ Object
- #setup(root: '.') ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/praxis/application.rb', line 24 def initialize @controllers = Set.new @resource_definitions = Set.new @router = Router.new(self) @bootloader = Bootloader.new(self) @file_layout = nil @plugins = Array.new @loaded_files = Set.new @config = Config.new @root = nil @logger = Logger.new(STDOUT) end |
Instance Attribute Details
#bootloader ⇒ Object
Returns the value of attribute bootloader.
13 14 15 |
# File 'lib/praxis/application.rb', line 13 def bootloader @bootloader end |
#controllers ⇒ Object (readonly)
Returns the value of attribute controllers.
10 11 12 |
# File 'lib/praxis/application.rb', line 10 def controllers @controllers end |
#file_layout ⇒ Object
Returns the value of attribute file_layout.
14 15 16 |
# File 'lib/praxis/application.rb', line 14 def file_layout @file_layout end |
#loaded_files ⇒ Object
Returns the value of attribute loaded_files.
15 16 17 |
# File 'lib/praxis/application.rb', line 15 def loaded_files @loaded_files end |
#logger ⇒ Object
Returns the value of attribute logger.
16 17 18 |
# File 'lib/praxis/application.rb', line 16 def logger @logger end |
#plugins ⇒ Object
Returns the value of attribute plugins.
17 18 19 |
# File 'lib/praxis/application.rb', line 17 def plugins @plugins end |
#resource_definitions ⇒ Object (readonly)
Returns the value of attribute resource_definitions.
11 12 13 |
# File 'lib/praxis/application.rb', line 11 def resource_definitions @resource_definitions end |
#root ⇒ Object
Returns the value of attribute root.
18 19 20 |
# File 'lib/praxis/application.rb', line 18 def root @root end |
#router ⇒ Object (readonly)
Returns the value of attribute router.
9 10 11 |
# File 'lib/praxis/application.rb', line 9 def router @router end |
Class Method Details
.configure {|self.instance| ... } ⇒ Object
20 21 22 |
# File 'lib/praxis/application.rb', line 20 def self.configure yield(self.instance) end |
Instance Method Details
#call(env) ⇒ Object
46 47 48 |
# File 'lib/praxis/application.rb', line 46 def call(env) self.router.call(env) end |
#config(key = nil, type = Attributor::Struct, **opts, &block) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/praxis/application.rb', line 54 def config(key=nil, type=Attributor::Struct, **opts, &block) if block_given? || (type==Attributor::Struct && !opts.empty? ) @config.define(key, type, opts, &block) else @config.get end end |
#config=(config) ⇒ Object
62 63 64 |
# File 'lib/praxis/application.rb', line 62 def config=(config) @config.set(config) end |
#layout(&block) ⇒ Object
50 51 52 |
# File 'lib/praxis/application.rb', line 50 def layout(&block) self.file_layout = FileGroup.new(self.root, &block) end |
#setup(root: '.') ⇒ Object
39 40 41 42 43 44 |
# File 'lib/praxis/application.rb', line 39 def setup(root: '.') @root = Pathname.new(root). @bootloader.setup! self end |