lib/lotus/configuration.rb in lotusrb-0.3.1 vs lib/lotus/configuration.rb in lotusrb-0.3.2

- old
+ new

@@ -463,14 +463,13 @@ # # This is part of a DSL, for this reason when this method is called with # an argument, it will set the corresponding instance variable. When # called without, it will return the already set value, or the default. # - # @overload cookies(value, options) + # @overload cookies(options) # Sets the given value with their options. - # @param value [TrueClass, FalseClass] - # @param options [Hash] + # @param options [Hash, TrueClass, FalseClass] # # @overload cookies # Gets the value. # @return [Lotus::Config::Cookies] # @@ -481,45 +480,29 @@ # class Application < Lotus::Application # end # end # # Bookshelf::Application.configuration.cookies - # # => #<Lotus::Config::Cookies:0x0000000329f880 @enabled=false, @default_options={:httponly=>true}> + # # => #<Lotus::Config::Cookies:0x0000000329f880 @options={}, @default_options={:httponly=>true, :secure=>false}> # # @example Setting the value # require 'lotus' # # module Bookshelf # class Application < Lotus::Application # configure do - # cookies true, { domain: 'lotusrb.org' } + # cookies domain: 'lotusrb.org' # end # end # end # # Bookshelf::Application.configuration.cookies - # # => #<Lotus::Config::Cookies:0x0000000329f880 @enabled=true, @default_options={:domain=>'lotusrb.org', :httponly=>true}> - # - # @example Setting a new value after one is set. - # require 'lotus' - # - # module Bookshelf - # class Application < Lotus::Application - # configure do - # cookies false - # cookies true - # end - # end - # end - # - # Bookshelf::Application.configuration.cookies - # # => #<Lotus::Config::Cookies:0x0000000329f880 @enabled=true, @default_options={:httponly=>true}> - # - def cookies(value = nil, options = {}) - if value.nil? - @cookies ||= Config::Cookies.new + # # => #<Lotus::Config::Cookies:0x0000000329f880 @options={:domain=>'lotusrb.org'}, @default_options={:domain=>'lotusrb.org', :httponly=>true, :secure=>false}> + def cookies(options = nil) + if options.nil? + @cookies ||= Config::Cookies.new(self, options) else - @cookies = Config::Cookies.new(value, options) + @cookies = Config::Cookies.new(self, options) end end # Configure sessions # Enable sessions (disabled by default).