Module: Servitude::Base::ClassMethods
- Defined in:
- lib/servitude/base.rb
Instance Method Summary collapse
- #boot(app_id: ( host_namespace.name.split( '::' ).join( '-' ).downcase rescue nil ), app_name: ( host_namespace.name.split( '::' ).join( ' ' ) rescue nil ), author: nil, attribution: ( "v#{host_namespace::VERSION} Copyright © #{Time.now.year} #{author}" rescue nil ), use_config: false, default_config_path: nil, server_class: ( host_namespace::Server rescue "#{host_namespace.name}::Server" )) ⇒ Object
- #configure {|configuration| ... } ⇒ Object
-
#host_namespace ⇒ Object
Override to contradict convention of Server being nested in ::host_namespace.
- #initialize_loggers(log_level: nil, filename: nil) ⇒ Object
- #server_class ⇒ Object
Instance Method Details
#boot(app_id: ( host_namespace.name.split( '::' ).join( '-' ).downcase rescue nil ), app_name: ( host_namespace.name.split( '::' ).join( ' ' ) rescue nil ), author: nil, attribution: ( "v#{host_namespace::VERSION} Copyright © #{Time.now.year} #{author}" rescue nil ), use_config: false, default_config_path: nil, server_class: ( host_namespace::Server rescue "#{host_namespace.name}::Server" )) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/servitude/base.rb', line 21 def boot( app_id: ( host_namespace.name.split( '::' ).join( '-' ).downcase rescue nil ), app_name: ( host_namespace.name.split( '::' ).join( ' ' ) rescue nil ), author: nil, attribution: ( "v#{host_namespace::VERSION} Copyright © #{Time.now.year} #{author}" rescue nil ), use_config: false, default_config_path: nil, server_class: ( host_namespace::Server rescue "#{host_namespace.name}::Server" )) unless app_id raise ArgumentError, 'app_id keyword is required' end unless app_name raise ArgumentError, 'app_name keyword is required' end unless raise ArgumentError, 'author keyword is required' end unless attribution raise ArgumentError, 'attribution keyword is required' end unless server_class raise ArgumentError, 'server_class keyword is required' end const_set :APP_ID, app_id const_set :APP_NAME, app_name const_set :AUTHOR, const_set :ATTRIBUTION, attribution const_set :DEFAULT_CONFIG_PATH, default_config_path const_set :SERVER_CLASS, server_class const_set :USE_CONFIG, use_config host_namespace.boot_called = true end |
#configure {|configuration| ... } ⇒ Object
88 89 90 |
# File 'lib/servitude/base.rb', line 88 def configure yield( configuration ) if block_given? end |
#host_namespace ⇒ Object
Override to contradict convention of Server being nested in ::host_namespace
59 60 61 |
# File 'lib/servitude/base.rb', line 59 def host_namespace self end |
#initialize_loggers(log_level: nil, filename: nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/servitude/base.rb', line 72 def initialize_loggers( log_level: nil, filename: nil ) raise ArgumentError, 'log_level keyword is required' unless log_level logger.adapter.close if logger && logger.adapter self.logger = Yell.new do |l| l.level = log_level if filename l.adapter :file, filename, :level => [:debug, :info, :warn] else l.adapter $stdout, :level => [:debug, :info, :warn] l.adapter $stderr, :level => [:error, :fatal] end end end |
#server_class ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/servitude/base.rb', line 63 def server_class case self::SERVER_CLASS when String, Symbol eval self::SERVER_CLASS.to_s, binding, __FILE__, __LINE__ else self::SERVER_CLASS end end |