Module: DataMapper::Form::Helpers
- Defined in:
- lib/dm-forms/helpers.rb
Instance Method Summary collapse
- #bound?(*args) ⇒ Boolean
- #buffer(string = nil) ⇒ Object
- #capture(&block) ⇒ Object
- #clear_buffer ⇒ Object
- #fields_for(model, attrs = {}, &block) ⇒ Object
- #form_context(*args) ⇒ Object
-
#new_form_context(*args) ⇒ Object
:nodoc:.
- #submit(value = nil, attrs = {}) ⇒ Object
- #with_form_context(model, attrs = {}, &block) ⇒ Object
Instance Method Details
#bound?(*args) ⇒ Boolean
60 61 62 |
# File 'lib/dm-forms/helpers.rb', line 60 def bound? *args args.first.is_a? Symbol end |
#buffer(string = nil) ⇒ Object
68 69 70 |
# File 'lib/dm-forms/helpers.rb', line 68 def buffer string = nil @buffer ||= '' end |
#capture(&block) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/dm-forms/helpers.rb', line 72 def capture &block if block.arity > 0 yield self else instance_eval &block end buffer end |
#clear_buffer ⇒ Object
64 65 66 |
# File 'lib/dm-forms/helpers.rb', line 64 def clear_buffer @buffer = '' end |
#fields_for(model, attrs = {}, &block) ⇒ Object
6 7 8 9 10 |
# File 'lib/dm-forms/helpers.rb', line 6 def fields_for model, attrs = {}, &block with_form_context model do capture &block end end |
#form_context(*args) ⇒ Object
49 50 51 |
# File 'lib/dm-forms/helpers.rb', line 49 def form_context *args @__form_context ||= new_form_context *args end |
#new_form_context(*args) ⇒ Object
:nodoc:
45 46 47 |
# File 'lib/dm-forms/helpers.rb', line 45 def new_form_context *args Base.new *args end |
#submit(value = nil, attrs = {}) ⇒ Object
12 13 14 15 |
# File 'lib/dm-forms/helpers.rb', line 12 def submit value = nil, attrs = {} attrs[:value] = value unless value.blank? form_context(nil, self).unbound_submit attrs end |
#with_form_context(model, attrs = {}, &block) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/dm-forms/helpers.rb', line 53 def with_form_context model, attrs = {}, &block last_context, @__form_context = form_context, new_form_context(model, self) captured = instance_eval &block @__form_context = last_context captured end |