Sha256: ddc031408e88fd0d9cde51f59d538a46168a35ac267f6fa793ae3c201953f829

Contents?: true

Size: 1.54 KB

Versions: 17

Compression:

Stored size: 1.54 KB

Contents

require 'caracal/core/models/base_model'


module Caracal
  module Core
    module Models

      # This class encapsulates the logic needed to store and manipulate
      # namespace data.
      #
      class NamespaceModel < BaseModel

        #-------------------------------------------------------------
        # Configuration
        #-------------------------------------------------------------

        # accessors
        attr_reader :namespace_prefix
        attr_reader :namespace_href



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

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

        # strings
        [:href, :prefix].each do |m|
          define_method "#{ m }" do |value|
            instance_variable_set("@namespace_#{ m }", value.to_s)
          end
        end


        #=================== STATE ===============================

        def matches?(str)
          namespace_prefix == str.to_s
        end


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

        def valid?
          required = [:href, :prefix]
          required.all? { |m| !send("namespace_#{ m }").nil? }
        end


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

        def option_keys
          [:prefix, :href]
        end

      end

    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

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