module Parcels::Fortitude::Enabling::ClassMethods

Public Instance Methods

_parcels_ensure_all_tag_methods_overridden!() click to toggle source
Calls superclass method
# File lib/parcels/fortitude/enabling.rb, line 45
def _parcels_ensure_all_tag_methods_overridden!
  tags.each do |tag_name, tag_object|
    done = _parcels_tag_method_overridden?(tag_name)
    next if done

    tag_object.all_method_names.each do |tag_method_name|
      @_parcels_tag_methods_module.send(:define_method, tag_method_name) do |*args, &block|
        content_or_attributes = args[0]
        attributes = args[1]

        directly_inside = rendering_context.current_element_nesting.last
        if directly_inside.kind_of?(::Fortitude::Widget) && (css_wrapper_classes = directly_inside.class.try(:_parcels_widget_outer_element_classes))
          if attributes || content_or_attributes.kind_of?(String)
            super(content_or_attributes, self.class._parcels_add_wrapper_css_classes_to(attributes, css_wrapper_classes), &block)
          else
            super(self.class._parcels_add_wrapper_css_classes_to(content_or_attributes, css_wrapper_classes), attributes, &block)
          end
        else
          super(content_or_attributes, attributes, &block)
        end
      end
    end
  end
end
_parcels_tag_method_overridden!(tag_name) click to toggle source
# File lib/parcels/fortitude/enabling.rb, line 41
def _parcels_tag_method_overridden!(tag_name)
  @_parcels_tag_methods_overridden[tag_name.to_sym] = true
end
_parcels_tag_method_overridden?(tag_name) click to toggle source
# File lib/parcels/fortitude/enabling.rb, line 36
def _parcels_tag_method_overridden?(tag_name)
  @_parcels_tag_methods_overridden ||= { }
  @_parcels_tag_methods_overridden[tag_name.to_sym]
end
enable_parcels!() click to toggle source
# File lib/parcels/fortitude/enabling.rb, line 17
def enable_parcels!
  raise "Already enabled on #{self}!" if @_parcels_enabled

  record_tag_emission true

  @_parcels_tag_methods_module = Module.new
  const_set(:ParcelsEnablingModule, @_parcels_tag_methods_module)
  include @_parcels_tag_methods_module

  _parcels_ensure_all_tag_methods_overridden!

  @_parcels_enabled = true
end
parcels_enabled?() click to toggle source
# File lib/parcels/fortitude/enabling.rb, line 10
def parcels_enabled?
  out = false
  out = true if superclass.respond_to?(:parcels_enabled?) && superclass.parcels_enabled?
  out = true if @_parcels_enabled
  out
end
tags_changed!(tags) click to toggle source
Calls superclass method
# File lib/parcels/fortitude/enabling.rb, line 31
def tags_changed!(tags)
  super
  _parcels_ensure_all_tag_methods_overridden! if parcels_enabled?
end