Sha256: 3b2e5c2c19f139e7a310b85c397deb1c7fd00eebd7d45d69ccac0323ca657582

Contents?: true

Size: 1.59 KB

Versions: 4

Compression:

Stored size: 1.59 KB

Contents

require 'active_support'
require 'active_support/concern'

require 'fortitude/tags/tag_store'

module Fortitude
  class Widget
    module Tags
      extend ActiveSupport::Concern

      included do
        extend Fortitude::Tags::TagStore

        class << self
          # INTERNAL USE ONLY
          def tags_changed!(tags)
            rebuild_tag_methods!(:tags_declared, tags)
          end
          private :tags_changed!

          # INTERNAL USE ONLY
          def delegate_tag_stores
            out = [ doctype ]

            out += superclass.delegate_tag_stores if superclass.respond_to?(:delegate_tag_stores)
            out << superclass if superclass.respond_to?(:tags)

            out.compact.uniq
          end
        end
      end

      module ClassMethods
        # INTERNAL USE ONLY
        def rebuild_tag_methods!(why, which_tags_in = nil, klass = self)
          rebuilding(:tag_methods, why, klass) do
            all_tags = tags.values

            which_tags = Array(which_tags_in || all_tags)
            which_tags.each do |tag_object|
              tag_object.define_method_on!(tags_module,
                :enable_formatting => self.format_output,
                :enforce_element_nesting_rules => self.enforce_element_nesting_rules,
                :enforce_attribute_rules => self.enforce_attribute_rules,
                :enforce_id_uniqueness => self.enforce_id_uniqueness,
                :close_void_tags => self.close_void_tags)
            end

            direct_subclasses.each { |s| s.rebuild_tag_methods!(why, which_tags_in, klass) }
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fortitude-0.0.4-java lib/fortitude/widget/tags.rb
fortitude-0.0.4 lib/fortitude/widget/tags.rb
fortitude-0.0.3 lib/fortitude/widget/tags.rb
fortitude-0.0.2 lib/fortitude/widget/tags.rb