Sha256: 5ba80c9fbd88f5da07feab01934bd18bed73aeaa5db1dfa535ef41de5b7909a9

Contents?: true

Size: 868 Bytes

Versions: 24

Compression:

Stored size: 868 Bytes

Contents

module KepplerCapsules
  class CapsuleField < ApplicationRecord
    include KepplerCapsules::Concerns::StringActions
    include KepplerCapsules::Concerns::GeneratorActions
    belongs_to :capsule
    validates_presence_of :name_field
    before_validation :convert_to_downcase, :without_special_characters


    def destroy_migrate
      delete_field_pg_table("keppler_capsules_#{self.capsule.name}", self.name_field)
      system('rake keppler_capsules:install:migrations')
      system('rake db:migrate')
    end

    def formats
      [ :string, :text, :integer, :float, :decimal, :date, :boolean, :association ]
    end

    private

    def convert_to_downcase
      self.name_field.downcase!
    end

    def without_special_characters
      self.name_field.gsub!(' ', '_')
      special_characters.each { |sc| self.name_field.gsub!(sc, '') }
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
keppler-2.1.22 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.21 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.20 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.19 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.18 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.17 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.16 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.15 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.14 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.13 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.12 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.11 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.10 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.9 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.8 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.7 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.6 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.5 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.4 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb
keppler-2.1.3 installer/core/rockets/keppler_capsules/app/models/keppler_capsules/capsule_field.rb