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

Instance Method Details

#_find_select_option(name, id_or_name) ⇒ Object



193
194
195
196
197
# File 'lib/custom_fields/types/select.rb', line 193

def _find_select_option(name, id_or_name)
  self.class._select_options(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



199
200
201
202
# File 'lib/custom_fields/types/select.rb', line 199

def _get_select_option(name)
  option = _find_select_option(name, _select_option_id(name))
  option ? option['name'] : nil
end

#_select_option_id(name) ⇒ Object



189
190
191
# File 'lib/custom_fields/types/select.rb', line 189

def _select_option_id(name)
  send(:"#{name}_id")
end

#_set_select_option(name, value) ⇒ Object



204
205
206
207
# File 'lib/custom_fields/types/select.rb', line 204

def _set_select_option(name, value)
  option = _find_select_option(name, value)
  send(:"#{name}_id=", option ? option['_id'] : nil)
end