Skip to content

Commit

Permalink
Rename Configuration#modules to #prepare
Browse files Browse the repository at this point in the history
[resolves #57]
  • Loading branch information
Trung Lê committed Dec 5, 2014
1 parent 87eef1d commit 58af8e3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
26 changes: 16 additions & 10 deletions lib/lotus/controller/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,12 @@ def action_module(value = nil)
# If not set, this option will be ignored.
#
# 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.
# an argument, it will set the corresponding instance variable.
#
# @overload modules(blk)
# @overload prepare(blk)
# Adds the given block
# @param value [Proc] specify the modules to be included
#
# @overload modules
# Gets the value
# @return [Array] the list of the specified procs
#
# @since 0.2.0
#
# @see Lotus::Controller::Dsl#action
Expand All @@ -307,9 +302,10 @@ def action_module(value = nil)
# require 'lotus/action/session'
#
# Lotus::Controller.configure do
# modules do
# prepare do
# include Lotus::Action::Cookies
# include Lotus::Action::Session
# before { do_something }
# end
# end
#
Expand All @@ -326,11 +322,11 @@ def action_module(value = nil)
# end
# end
# end
def modules(&blk)
def prepare(&blk)
if block_given?
@modules.push(blk)
else
@modules
raise ArgumentError.new('Please provide a proc or a block')
end
end

Expand Down Expand Up @@ -507,6 +503,16 @@ def duplicate
end
end

# Return included modules
#
# @return [Array<Proc>] array of included modules
#
# @since 0.2.0
# @api private
#
# @see Lotus::Controller::Configuration#prepare
attr_reader :modules

# Reset all the values to the defaults
#
# @since 0.2.0
Expand Down
10 changes: 5 additions & 5 deletions test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ def status

describe 'when previously configured' do
before do
@configuration.modules do
@configuration.prepare do
include FakeCallable
end
end

it 'allows to configure additional modules to include' do
@configuration.modules do
@configuration.prepare do
include FakeStatus
end

Expand All @@ -137,7 +137,7 @@ def status
end

it 'allows to configure modules to include' do
@configuration.modules do
@configuration.prepare do
include FakeCallable
end

Expand Down Expand Up @@ -265,7 +265,7 @@ def hash
describe 'duplicate' do
before do
@configuration.reset!
@configuration.modules { include Kernel }
@configuration.prepare { include Kernel }
@configuration.format custom: 'custom/format'
@configuration.default_format :html
@configuration.default_charset 'latin1'
Expand All @@ -286,7 +286,7 @@ def hash
@config.handle_exceptions = false
@config.handle_exception ArgumentError => 400
@config.action_module CustomAction
@config.modules { include Comparable }
@config.prepare { include Comparable }
@config.format another: 'another/format'
@config.default_format :json
@config.default_charset 'utf-8'
Expand Down

0 comments on commit 58af8e3

Please sign in to comment.