Sha256: 3da92dd9ecf7daf93355400e9ac19798f6db0d83abd547937dbad7b15b361077

Contents?: true

Size: 1.03 KB

Versions: 37

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require "active_support/core_ext/module/attribute_accessors"

module ActionView
  class Template # :nodoc:
    module 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

      class << self
        attr_accessor :type_klass

        def delegate_to(klass)
          self.type_klass = klass
        end

        def [](type)
          type_klass[type]
        end

        def symbols
          type_klass::SET.symbols
        end
      end

      delegate_to Type
    end
  end
end

Version data entries

37 entries across 35 versions & 4 rubygems

Version Path
actionview-7.0.8.6 lib/action_view/template/types.rb
actionview-7.0.8.5 lib/action_view/template/types.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actionview-7.0.8.4/lib/action_view/template/types.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/actionview-7.0.5.1/lib/action_view/template/types.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/actionview-7.0.5.1/lib/action_view/template/types.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/actionview-7.0.5.1/lib/action_view/template/types.rb
actionview-7.0.8.4 lib/action_view/template/types.rb
actionview-7.0.8.1 lib/action_view/template/types.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionview-7.0.3.1/lib/action_view/template/types.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionview-7.0.2.3/lib/action_view/template/types.rb
actionview-7.0.8 lib/action_view/template/types.rb
actionview-7.0.7.2 lib/action_view/template/types.rb
actionview-7.0.7.1 lib/action_view/template/types.rb
actionview-7.0.7 lib/action_view/template/types.rb
actionview-7.0.6 lib/action_view/template/types.rb
actionview-7.0.5.1 lib/action_view/template/types.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actionview-7.0.2.3/lib/action_view/template/types.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actionview-7.0.3.1/lib/action_view/template/types.rb
actionview-7.0.5 lib/action_view/template/types.rb
actionview-7.0.4.3 lib/action_view/template/types.rb