Class: Pageflow::Admin::FormInputs
- Inherits:
-
Object
- Object
- Pageflow::Admin::FormInputs
- Defined in:
- lib/pageflow/admin/form_inputs.rb
Overview
A registry of additional inputs for admin forms.
Instance Method Summary collapse
- #build(resource_name, form_builder) ⇒ Object private
- #find_all_for(resource_name) ⇒ Object private
-
#initialize ⇒ FormInputs
constructor
A new instance of FormInputs.
- #permitted_attributes_for(resource_name) ⇒ Object private
-
#register(resource_name, attribute_name, options = {}) ⇒ Object
Register a proc which adds additional inputs to admin forms.
Constructor Details
#initialize ⇒ FormInputs
Returns a new instance of FormInputs.
7 8 9 |
# File 'lib/pageflow/admin/form_inputs.rb', line 7 def initialize @resources = {} end |
Instance Method Details
#build(resource_name, form_builder) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 |
# File 'lib/pageflow/admin/form_inputs.rb', line 24 def build(resource_name, form_builder) find_all_for(resource_name).each do |form_input| form_input.build(form_builder) end end |
#find_all_for(resource_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/pageflow/admin/form_inputs.rb', line 36 def find_all_for(resource_name) @resources.fetch(resource_name, []) end |
#permitted_attributes_for(resource_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/pageflow/admin/form_inputs.rb', line 31 def permitted_attributes_for(resource_name) find_all_for(resource_name).map(&:attribute_name) end |
#register(resource_name, attribute_name, options = {}) ⇒ Object
Register a proc which adds additional inputs to admin forms.
18 19 20 21 |
# File 'lib/pageflow/admin/form_inputs.rb', line 18 def register(resource_name, attribute_name, = {}) @resources[resource_name] ||= [] @resources[resource_name] << FormInput.new(attribute_name, ) end |