Module: RailsDefaults::OPTS
- Included in:
- RailsDefaults
- Defined in:
- lib/rails-defaults.rb
Instance Method Summary collapse
- #daemonize(obj = nil? ) ⇒ Object
- #debugger(obj = nil) ⇒ Object
- #environment(obj = nil) ⇒ Object (also: #env)
- #options(opts = {}) ⇒ Object (also: #opts)
- #port(obj = nil) ⇒ Object
- #server(server_name = nil) ⇒ Object
Instance Method Details
#daemonize(obj = nil? ) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/rails-defaults.rb', line 45 def daemonize obj= nil? unless obj.nil? Helpers.must_be_instance_of obj, TrueClass,FalseClass @daemonize= obj end return @daemonize || false end |
#debugger(obj = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/rails-defaults.rb', line 37 def debugger obj= nil unless obj.nil? Helpers.must_be_instance_of obj, TrueClass,FalseClass @debugger= obj end return @debugger || false end |
#environment(obj = nil) ⇒ Object Also known as: env
72 73 74 75 76 77 78 |
# File 'lib/rails-defaults.rb', line 72 def environment obj= nil unless obj.nil? Helpers.must_be_instance_of obj, String,Symbol @environment= obj.to_s end return @environment || "development" end |
#options(opts = {}) ⇒ Object Also known as: opts
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/rails-defaults.rb', line 82 def opts= {} opts.each do |method_name, value| begin self.__send__ method_name.to_s.downcase, value rescue NoMethodError raise ArgumentError, "invalid key #{method_name}, try use one from the followings: #{self.singleton_methods-[:opts,:options]}" end end end |
#port(obj = nil) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/rails-defaults.rb', line 29 def port obj= nil unless obj.nil? Helpers.must_be_instance_of obj, Numeric, Symbol, String @port= obj.to_i end return @port || 3000 end |
#server(server_name = nil) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rails-defaults.rb', line 53 def server server_name= nil unless server_name.nil? Helpers.must_be_instance_of server_name, String, Symbol @server= server_name end ###OLD WORKAROUND #require 'rack/handler' #begin # eval " ::Rack::Handler::WEBrick = Rack::Handler.get(server_name)" #rescue LoadError # STDERR.puts("#{server_name} gem is not installed, using WEBrick as default") #end return @server || :webrick end |