Class: MoveToGo::ClassSettings
- Inherits:
-
Object
- Object
- MoveToGo::ClassSettings
- Includes:
- SerializeHelper
- Defined in:
- lib/move-to-go/model/class_settings.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#custom_fields ⇒ Object
readonly
Returns the value of attribute custom_fields.
Instance Method Summary collapse
-
#initialize(opt = nil) ⇒ ClassSettings
constructor
A new instance of ClassSettings.
- #serialize_name ⇒ Object
- #serialize_variables ⇒ Object
-
#set_custom_field(obj) ⇒ Object
Set custom field.
Methods included from SerializeHelper
#get_import_rows, #serialize, #serialize_to_file
Constructor Details
#initialize(opt = nil) ⇒ ClassSettings
Returns a new instance of ClassSettings.
7 8 9 10 11 12 13 14 |
# File 'lib/move-to-go/model/class_settings.rb', line 7 def initialize(opt = nil) if opt != nil serialize_variables.each do |myattr| val = opt[myattr[:id]] instance_variable_set("@" + myattr[:id].to_s, val) if val != nil end end end |
Instance Attribute Details
#custom_fields ⇒ Object (readonly)
Returns the value of attribute custom_fields.
5 6 7 |
# File 'lib/move-to-go/model/class_settings.rb', line 5 def custom_fields @custom_fields end |
Instance Method Details
#serialize_name ⇒ Object
20 21 22 |
# File 'lib/move-to-go/model/class_settings.rb', line 20 def serialize_name "ClassSettings" end |
#serialize_variables ⇒ Object
16 17 18 |
# File 'lib/move-to-go/model/class_settings.rb', line 16 def serialize_variables [{:id => :custom_fields, :type => :custom_fields} ] end |
#set_custom_field(obj) ⇒ Object
Set custom field. If there is already an existing custom field, then it is overwritten.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/move-to-go/model/class_settings.rb', line 25 def set_custom_field(obj) @custom_fields = [] if @custom_fields.nil? if obj.is_a?(CustomField) field = obj else field = CustomField.new(obj) end if field.integration_id == "" && field.id == "" raise InvalidCustomFieldError, "Custom field must have either id or integration_id" end index = @custom_fields.find_index do |custom_field| custom_field.same_as?(field) end if index @custom_fields.delete_at index end @custom_fields.push field return field end |