Module: ActiveAdminAddons::InputOptionsHandler
- Included in:
- InputBase, SelectHelpers
- Defined in:
- lib/activeadmin_addons/support/input_helpers/input_options_handler.rb
Instance Method Summary collapse
- #attr_options ⇒ Object
- #control_attributes ⇒ Object
- #css_classes ⇒ Object
- #data_attr_options ⇒ Object
- #get_data_attr_value(attr_name) ⇒ Object
- #load_attr(attr_name, options = {}) ⇒ Object
- #load_class(class_attr) ⇒ Object
- #load_data_attr(attr_name, options = {}) ⇒ Object
Instance Method Details
#attr_options ⇒ Object
23 24 25 |
# File 'lib/activeadmin_addons/support/input_helpers/input_options_handler.rb', line 23 def @attr_options || {} end |
#control_attributes ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/activeadmin_addons/support/input_helpers/input_options_handler.rb', line 3 def control_attributes result = {} result[:class] = css_classes.compact.join(" ") if css_classes.any? .each do |attribute, item| result[:data] ||= {} result[:data][attribute] = formatted_option_value(item) end .each do |attribute, item| result[attribute] = formatted_option_value(item) end result end |
#css_classes ⇒ Object
27 28 29 |
# File 'lib/activeadmin_addons/support/input_helpers/input_options_handler.rb', line 27 def css_classes @css_classes || [] end |
#data_attr_options ⇒ Object
19 20 21 |
# File 'lib/activeadmin_addons/support/input_helpers/input_options_handler.rb', line 19 def @data_attr_options || {} end |
#get_data_attr_value(attr_name) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/activeadmin_addons/support/input_helpers/input_options_handler.rb', line 50 def get_data_attr_value(attr_name) item = [attr_name.to_sym] return unless item item[:value] end |
#load_attr(attr_name, options = {}) ⇒ Object
36 37 38 39 |
# File 'lib/activeadmin_addons/support/input_helpers/input_options_handler.rb', line 36 def load_attr(attr_name, = {}) @attr_options ||= {} @attr_options[attr_name.to_sym] = load_option_attr(attr_name, ) end |
#load_class(class_attr) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/activeadmin_addons/support/input_helpers/input_options_handler.rb', line 41 def load_class(class_attr) @css_classes ||= [] return if class_attr.blank? class_attr = class_attr.strip @css_classes << class_attr class_attr end |
#load_data_attr(attr_name, options = {}) ⇒ Object
31 32 33 34 |
# File 'lib/activeadmin_addons/support/input_helpers/input_options_handler.rb', line 31 def load_data_attr(attr_name, = {}) @data_attr_options ||= {} @data_attr_options[attr_name.to_sym] = load_option_attr(attr_name, ) end |