Sha256: f944556aecfe99e3b89e56c98f11f9685f3d20f9b81e841747b4038e1f9be7e8

Contents?: true

Size: 658 Bytes

Versions: 11

Compression:

Stored size: 658 Bytes

Contents

require 'genesis_ruby/utils/common'

module GenesisRuby
  module Api
    module Mixins
      module Constants
        # Common method between all Constant classes
        # use extend to add methods below to a specific module
        module Common

          # Get all defined constant values
          def all
            GenesisRuby::Utils::Common.constant_values(self)
          end

          # Validate given value against all available constant values
          def valid?(value, strict: false)
            value = value.downcase if !strict && value.is_a?(String)

            all.include?(value)
          end

        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
genesis_ruby-0.2.0 lib/genesis_ruby/api/mixins/constants/common.rb
genesis_ruby-0.1.9 lib/genesis_ruby/api/mixins/constants/common.rb
genesis_ruby-0.1.8 lib/genesis_ruby/api/mixins/constants/common.rb
genesis_ruby-0.1.7 lib/genesis_ruby/api/mixins/constants/common.rb
genesis_ruby-0.1.6 lib/genesis_ruby/api/mixins/constants/common.rb
genesis_ruby-0.1.5 lib/genesis_ruby/api/mixins/constants/common.rb
genesis_ruby-0.1.4 lib/genesis_ruby/api/mixins/constants/common.rb
genesis_ruby-0.1.3 lib/genesis_ruby/api/mixins/constants/common.rb
genesis_ruby-0.1.2 lib/genesis_ruby/api/mixins/constants/common.rb
genesis_ruby-0.1.1 lib/genesis_ruby/api/mixins/constants/common.rb
genesis_ruby-0.1.0 lib/genesis_ruby/api/mixins/constants/common.rb