Class: Locomotive::CustomFieldService

Inherits:
Struct
  • Object
show all
Defined in:
app/services/locomotive/custom_field_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fieldObject

Returns the value of attribute field

Returns:

  • (Object)

    the current value of field



2
3
4
# File 'app/services/locomotive/custom_field_service.rb', line 2

def field
  @field
end

Instance Method Details

#update_select_options(options) ⇒ Array

Update the options of a “select” field.

Parameters:

  • options (Hash)

    It includes the following keys: name, _id and _destroyed (if persisted)

Returns:

  • (Array)

    The new list of options



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/locomotive/custom_field_service.rb', line 10

def update_select_options(options)
  return nil if options.blank?

  # set the right position
  options.each_with_index do |option, position|
    option['position'] = position
  end

  self.field.select_options_attributes = options

  self.field.save

  self.field.select_options
end