-
Notifications
You must be signed in to change notification settings - Fork 7
/
form_performances_helper.rb
38 lines (33 loc) · 1.17 KB
/
form_performances_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module ActionView #:nodoc:
module Helpers #:nodoc:
# Provides methods for Performances forms
module FormPerformancesHelper
# Render Performances form for object
#
# Object must be a Stage
#
# Options:
# roles:: Array of Roles available
def performances(object, options = {})
InstanceTag.new(object, :performances, self, options.delete(:object)).to_performances_tag(options)
end
end
class InstanceTag #:nodoc:
include FormPerformancesHelper
def to_performances_tag(options)
options[:roles] = object.class.roles + Role.without_stage_type
# TODO
# raise "#{ object } isn't a Stage" unless object.acts_as_stage?
@template_object.render :partial => "stages/performances_form",
:locals => { :stage => object,
:stage_name => object_name,
:roles => options[:roles] }
end
end
class FormBuilder #:nodoc:
def performances(options = {})
@template.performances(@object_name, options.merge(:object => @object))
end
end
end
end