exposure 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/exposure/common.rb +21 -12
  2. data/lib/exposure.rb +1 -1
  3. metadata +2 -2
@@ -24,18 +24,19 @@ module Exposure
24
24
  # :formats
25
25
  # array of formats as symbols.
26
26
  # defaults to [:html]
27
- def response_for(action_name, options = {}, &block)
27
+ def response_for(*args, &block)
28
+ options = args.extract_options!
28
29
  options[:is] ||= block
29
30
  formats = options[:formats] || [:html]
30
31
 
31
32
  case options[:on]
32
33
  when NilClass, :any
33
- build_custom_response(action_name, :success, formats, options[:is])
34
- build_custom_response(action_name, :failure, formats, options[:is])
34
+ build_custom_response(args, :success, formats, options[:is])
35
+ build_custom_response(args, :failure, formats, options[:is])
35
36
  when :success
36
- build_custom_response(action_name, :success, formats, options[:is])
37
+ build_custom_response(args, :success, formats, options[:is])
37
38
  when :failure
38
- build_custom_response(action_name, :failure, formats, options[:is])
39
+ build_custom_response(args, :failure, formats, options[:is])
39
40
  end
40
41
  end
41
42
 
@@ -79,13 +80,19 @@ module Exposure
79
80
  end
80
81
 
81
82
  # access point for creating and configuring before_ callbacks.
82
- def before(trigger, action, options = {})
83
- build_callback('before', trigger, action, options)
83
+ def before(trigger, *actions)
84
+ options = actions.extract_options!
85
+ actions.each do |action|
86
+ build_callback('before', trigger, action, options)
87
+ end
84
88
  end
85
89
 
86
90
  # access point for creating and configuring before_ callbacks.
87
- def after(trigger, action, options = {})
88
- build_callback('after', trigger, action, options)
91
+ def after(trigger, *actions)
92
+ options = actions.extract_options!
93
+ actions.each do |action|
94
+ build_callback('after', trigger, action, options)
95
+ end
89
96
  end
90
97
 
91
98
  # builds default finders
@@ -101,9 +108,11 @@ module Exposure
101
108
  end
102
109
  end
103
110
 
104
- def build_custom_response(action_name, success_status, formats, response)
105
- formats.each do |format|
106
- self.const_get(:Responses)["#{action_name}.#{success_status}.#{format}"] = response
111
+ def build_custom_response(action_names, success_status, formats, response)
112
+ action_names.each do |action_name|
113
+ formats.each do |format|
114
+ self.const_get(:Responses)["#{action_name}.#{success_status}.#{format}"] = response
115
+ end
107
116
  end
108
117
  end
109
118
 
data/lib/exposure.rb CHANGED
@@ -7,7 +7,7 @@ require 'exposure/patterns/resources'
7
7
  require 'exposure/patterns/resource'
8
8
 
9
9
  module Exposure
10
- VERSION = '0.0.5'
10
+ VERSION = '0.0.6'
11
11
  def self.included(base)
12
12
  base.extend Configuration
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exposure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trek Glowacki
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-08 00:00:00 -04:00
12
+ date: 2009-10-09 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency