Sha256: a64b661a6b6b3a5263e60b416d46dedeef444ec5ff6d1c9a515985b5d07960ef

Contents?: true

Size: 1021 Bytes

Versions: 174

Compression:

Stored size: 1021 Bytes

Contents

# frozen_string_literal: true

require "active_support/core_ext/module/attribute_accessors"

module ActionView
  class Template #:nodoc:
    class Types
      class Type
        SET = Struct.new(:symbols).new([ :html, :text, :js, :css, :xml, :json ])

        def self.[](type)
          if type.is_a?(self)
            type
          else
            new(type)
          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

      cattr_accessor :type_klass

      def self.delegate_to(klass)
        self.type_klass = klass
      end

      delegate_to Type

      def self.[](type)
        type_klass[type]
      end

      def self.symbols
        type_klass::SET.symbols
      end
    end
  end
end

Version data entries

174 entries across 166 versions & 11 rubygems

Version Path
actionview-6.1.4.2 lib/action_view/template/types.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/actionview-6.1.4.1/lib/action_view/template/types.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/actionview-6.1.4.1/lib/action_view/template/types.rb
actionview-6.1.4.1 lib/action_view/template/types.rb
actionview-6.0.4.1 lib/action_view/template/types.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/actionview-6.1.4/lib/action_view/template/types.rb
actionview-6.1.4 lib/action_view/template/types.rb
actionview-6.0.4 lib/action_view/template/types.rb
actionview-5.2.6 lib/action_view/template/types.rb
actionview-6.0.3.7 lib/action_view/template/types.rb
actionview-6.1.3.2 lib/action_view/template/types.rb
actionview-5.2.4.6 lib/action_view/template/types.rb
actionview-6.1.3.1 lib/action_view/template/types.rb
actionview-6.0.3.6 lib/action_view/template/types.rb
actionview-5.2.5 lib/action_view/template/types.rb
actionview-6.1.3 lib/action_view/template/types.rb
actionview-6.1.2.1 lib/action_view/template/types.rb
actionview-6.0.3.5 lib/action_view/template/types.rb
actionview-5.2.4.5 lib/action_view/template/types.rb
actionview-6.1.2 lib/action_view/template/types.rb