Sha256: 3394a87fea18f68e164e6554df71f67f5415c7899fa5b52b722e0d6405e49535

Contents?: true

Size: 976 Bytes

Versions: 12

Compression:

Stored size: 976 Bytes

Contents

require 'delegate'

module Coprl
  module Presenters
    module WebClient
      class ComponentHtmlDecorator < SimpleDelegator

        def _plugins_
          __getobj__.send(:_plugins_)
        end

        def method_missing(meth, *args, &block)
          if respond_to?(meth)
            super
          else
            nil
          end
        end

        private

        HTML_ESCAPED_ATTRIBUTES = %i(
          id
          type
        )

        def self.html_escape_attribute(attr)
          define_method(attr) do
            self.class.html_escape(super())
          end
        end

        HTML_ESCAPED_ATTRIBUTES.each do |attr|
          html_escape_attribute(attr)
        end

        def self.inherited(subclass)
          subclass::HTML_ESCAPED_ATTRIBUTES.each do |attr|
            html_escape_attribute(attr)
          end
        end

        def self.html_escape(text)
          Rack::Utils.escape_html(text)
        end

      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
coprl-3.0.0.beta.12 lib/coprl/presenters/web_client/component_html_decorator.rb
coprl-3.0.0.beta.11 lib/coprl/presenters/web_client/component_html_decorator.rb
coprl-3.0.0.beta.10 lib/coprl/presenters/web_client/component_html_decorator.rb
coprl-3.0.0.beta.9 lib/coprl/presenters/web_client/component_html_decorator.rb
coprl-3.0.0.beta.8 lib/coprl/presenters/web_client/component_html_decorator.rb
coprl-3.0.0.beta.7 lib/coprl/presenters/web_client/component_html_decorator.rb
coprl-3.0.0.beta.6 lib/coprl/presenters/web_client/component_html_decorator.rb
coprl-3.0.0.beta.5 lib/coprl/presenters/web_client/component_html_decorator.rb
coprl-3.0.0.beta.4 lib/coprl/presenters/web_client/component_html_decorator.rb
coprl-3.0.0.beta.3 lib/coprl/presenters/web_client/component_html_decorator.rb
coprl-3.0.0.beta.2 lib/coprl/presenters/web_client/component_html_decorator.rb
coprl-3.0.0.beta.1 lib/coprl/presenters/web_client/component_html_decorator.rb