Class: Formatic::Choices::Options
- Inherits:
-
Object
- Object
- Formatic::Choices::Options
- Includes:
- Calls
- Defined in:
- lib/formatic/choices/options.rb
Overview
Returns raw options suitable for a <select> box.
Instance Method Summary collapse
Instance Method Details
#association ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/formatic/choices/options.rb', line 30 def association model_klass = f&.object&.class return false unless model_klass.respond_to?(:reflect_on_all_associations) model_klass.reflect_on_all_associations(:belongs_to) .detect { it.foreign_key == attribute_name.to_s } end |
#call ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/formatic/choices/options.rb', line 14 def call candidates = return candidates unless currently_associated_record && include_current return candidates if records&.include?(currently_associated_record) candidates.prepend currently_associated_record.presenters.for_select candidates end |
#currently_associated_record ⇒ Object
23 24 25 26 27 28 |
# File 'lib/formatic/choices/options.rb', line 23 def currently_associated_record return unless association return unless f.object f.object.public_send(association.name) end |