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
195 196 197 198 199 |
# File 'lib/custom_fields/types/select.rb', line 195 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
201 202 203 204 |
# File 'lib/custom_fields/types/select.rb', line 201 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
191 192 193 |
# File 'lib/custom_fields/types/select.rb', line 191 def _select_option_id(name) self.send(:"#{name}_id") end |
#_set_select_option(name, value) ⇒ Object
206 207 208 209 |
# File 'lib/custom_fields/types/select.rb', line 206 def _set_select_option(name, value) option = self._find_select_option(name, value) self.send(:"#{name}_id=", option ? option['_id'] : nil) end |