Sha256: 8eed2d93c5ff1ec9c47bf60e88c2aa0451fe66bf333fc0de5aca46834e19dadf

Contents?: true

Size: 1008 Bytes

Versions: 37

Compression:

Stored size: 1008 Bytes

Contents

# frozen_string_literal: true

require "active_support/core_ext/module/attribute_accessors"

module ActionView
  class Template # :nodoc:
    # SimpleType is mostly just a stub implementation for when Action View
    # is used without Action Dispatch.
    class SimpleType # :nodoc:
      @symbols = [ :html, :text, :js, :css, :xml, :json ]
      class << self
        attr_reader :symbols

        def [](type)
          if type.is_a?(self)
            type
          else
            new(type)
          end
        end

        def valid_symbols?(symbols) # :nodoc
          symbols.all? { |s| @symbols.include?(s) }
        end
      end

      attr_reader :symbol

      def initialize(symbol)
        @symbol = symbol.to_sym
      end

      def to_s
        @symbol.to_s
      end
      alias to_str to_s

      def ref
        @symbol
      end
      alias to_sym ref

      def ==(type)
        @symbol == type.to_sym unless type.blank?
      end
    end

    Types = SimpleType # :nodoc:
  end
end

Version data entries

37 entries across 37 versions & 5 rubygems

Version Path
actionview-8.0.0 lib/action_view/template/types.rb
actionview-7.2.2 lib/action_view/template/types.rb
actionview-7.1.5 lib/action_view/template/types.rb
actionview-8.0.0.rc2 lib/action_view/template/types.rb
actionview-7.2.1.2 lib/action_view/template/types.rb
actionview-7.1.4.2 lib/action_view/template/types.rb
actionview-8.0.0.rc1 lib/action_view/template/types.rb
actionview-7.2.1.1 lib/action_view/template/types.rb
actionview-7.1.4.1 lib/action_view/template/types.rb
actionview-8.0.0.beta1 lib/action_view/template/types.rb
omg-actionview-8.0.0.alpha9 lib/action_view/template/types.rb
omg-actionview-8.0.0.alpha8 lib/action_view/template/types.rb
omg-actionview-8.0.0.alpha7 lib/action_view/template/types.rb
omg-actionview-8.0.0.alpha4 lib/action_view/template/types.rb
omg-actionview-8.0.0.alpha3 lib/action_view/template/types.rb
omg-actionview-8.0.0.alpha2 lib/action_view/template/types.rb
omg-actionview-8.0.0.alpha1 lib/action_view/template/types.rb
actionview-7.1.4 lib/action_view/template/types.rb
actionview-7.2.1 lib/action_view/template/types.rb
actionview-7.2.0 lib/action_view/template/types.rb