Sha256: 7c065c3eaaa8d21f7e039a89912e8af4c212e928ba43ea4771ae4fcdc0adfc14

Contents?: true

Size: 1.36 KB

Versions: 24

Compression:

Stored size: 1.36 KB

Contents

require 'caracal/core/models/base_model'


module Caracal
  module Core
    module Models

      # This class encapsulates the logic needed to store and manipulate
      # custom properties
      #
      class CustomPropertyModel < BaseModel

        # accessors
        attr_reader :custom_property_name
        attr_reader :custom_property_value
        attr_reader :custom_property_type


        #-------------------------------------------------------------
        # Public Instance Methods
        #-------------------------------------------------------------


        #=================== SETTERS =============================

        def name(value)
          @custom_property_name = value.to_s
        end

        def value(value)
          @custom_property_value = value.to_s
        end

        def type(value)
          @custom_property_type = value.to_s
        end


        #=============== VALIDATION ===========================

        def valid?
          required = option_keys
          required.all? { |m| !send("custom_property_#{ m }").nil? }
        end

        
        #-------------------------------------------------------------
        # Private Instance Methods
        #-------------------------------------------------------------
        private

        def option_keys
          [:name, :value, :type]
        end

      end

    end
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
caracal_the_curve-1.4.6 lib/caracal/core/models/custom_property_model.rb
caracal_the_curve-1.4.5 lib/caracal/core/models/custom_property_model.rb
caracal_the_curve-1.4.4 lib/caracal/core/models/custom_property_model.rb
caracal_the_curve-1.4.3 lib/caracal/core/models/custom_property_model.rb
caracal_the_curve-1.4.2 lib/caracal/core/models/custom_property_model.rb
caracal_the_curve-1.4.1 lib/caracal/core/models/custom_property_model.rb
caracal-1.4.1 lib/caracal/core/models/custom_property_model.rb
caracal-1.4.0 lib/caracal/core/models/custom_property_model.rb
caracal-1.3.0 lib/caracal/core/models/custom_property_model.rb
caracal-1.2.0 lib/caracal/core/models/custom_property_model.rb
caracal-1.1.2 lib/caracal/core/models/custom_property_model.rb
caracal-1.1.1 lib/caracal/core/models/custom_property_model.rb
caracal-1.1.0 lib/caracal/core/models/custom_property_model.rb
caracal-1.0.13 lib/caracal/core/models/custom_property_model.rb
caracal-1.0.12 lib/caracal/core/models/custom_property_model.rb
caracal-1.0.11 lib/caracal/core/models/custom_property_model.rb
caracal-1.0.10 lib/caracal/core/models/custom_property_model.rb
caracal-1.0.9 lib/caracal/core/models/custom_property_model.rb
caracal-1.0.8 lib/caracal/core/models/custom_property_model.rb
caracal-1.0.7 lib/caracal/core/models/custom_property_model.rb