Sha256: 300bd57a83686a11a9d364e237bde9e3b59bff9366fceb178f54ab56260fb0c1

Contents?: true

Size: 975 Bytes

Versions: 6

Compression:

Stored size: 975 Bytes

Contents

require 'delegate'

module Voom
  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

6 entries across 6 versions & 1 rubygems

Version Path
voom-presenters-2.1.2 lib/voom/presenters/web_client/component_html_decorator.rb
voom-presenters-2.1.0 lib/voom/presenters/web_client/component_html_decorator.rb
voom-presenters-2.0.3 lib/voom/presenters/web_client/component_html_decorator.rb
voom-presenters-2.0.2 lib/voom/presenters/web_client/component_html_decorator.rb
voom-presenters-2.0.1 lib/voom/presenters/web_client/component_html_decorator.rb
voom-presenters-2.0.0 lib/voom/presenters/web_client/component_html_decorator.rb