Module: CustomFields::Types::Select::Target
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/custom_fields/types/select.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #_find_select_option(name, id_or_name) ⇒ Object
- #_get_select_option(name) ⇒ Object
- #_select_option_id(name) ⇒ Object
- #_set_select_option(name, value) ⇒ Object
Instance Method Details
#_find_select_option(name, id_or_name) ⇒ Object
197 198 199 200 201 |
# File 'lib/custom_fields/types/select.rb', line 197 def _find_select_option(name, id_or_name) self.class.(name).detect do |option| option['name'] == id_or_name || option['_id'].to_s == id_or_name.to_s end end |
#_get_select_option(name) ⇒ Object
203 204 205 206 |
# File 'lib/custom_fields/types/select.rb', line 203 def _get_select_option(name) option = self._find_select_option(name, self._select_option_id(name)) option ? option['name'] : nil end |
#_select_option_id(name) ⇒ Object
193 194 195 |
# File 'lib/custom_fields/types/select.rb', line 193 def _select_option_id(name) self.send(:"#{name}_id") end |
#_set_select_option(name, value) ⇒ Object
208 209 210 211 |
# File 'lib/custom_fields/types/select.rb', line 208 def _set_select_option(name, value) option = self._find_select_option(name, value) self.send(:"#{name}_id=", option ? option['_id'] : nil) end |