Class: RailsSettingsUi::ValueTypes::Array

Inherits:
Base
  • Object
show all
Defined in:
lib/rails-settings-ui/value_types/array.rb

Instance Attribute Summary

Attributes inherited from Base

#errors, #value

Instance Method Summary collapse

Methods inherited from Base

#initialize, #valid?, #value_numeric?

Constructor Details

This class inherits a constructor from RailsSettingsUi::ValueTypes::Base

Instance Method Details

#castObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rails-settings-ui/value_types/array.rb', line 6

def cast
  # Array presented in checkboxes
  if ["Hash", "ActiveSupport::HashWithIndifferentAccess"].include?(value.class.name)
    value.keys.map!(&:to_sym)
  elsif value.class.name == 'ActionController::Parameters'
    value.reject{|_,v| v!='on' }.keys.map!(&:to_sym)
  # or in select tag
  else
    value.to_sym
  end
end