Netzke::Composition::ClassMethods

Public Instance Methods

component(name, config = {}, █) click to toggle source

Defines a nested component.

# File lib/netzke/composition.rb, line 58
def component(name, config = {}, &block)
  register_component(name)
  config = config.dup
  config[:class_name] ||= name.to_s.camelize
  config[:name] = name.to_s
  method_name = COMPONENT_METHOD_NAME % name
  if block_given?
    define_method(method_name, &block)
  else
    if superclass.instance_methods.map(&:to_s).include?(method_name)
      define_method(method_name) do
        super().merge(config)
      end
    else
      define_method(method_name) do
        config
      end
    end
  end
end
js_component(name, config = {}) click to toggle source

DEPRECATED in favor of Symbol#component Component’s js config used when embedding components as Container’s items (see some_composite.rb for an example)

# File lib/netzke/composition.rb, line 83
def js_component(name, config = {})
  ::ActiveSupport::Deprecation.warn("Using js_component is deprecated. Use Symbol#component instead", caller)
  config.merge(:component => name)
end
register_component(name) click to toggle source

Register a component

# File lib/netzke/composition.rb, line 89
def register_component(name)
  current_components = read_inheritable_attribute(:components) || []
  current_components << name
  write_inheritable_attribute(:components, current_components.uniq)
end
registered_components() click to toggle source

Returns registered components

# File lib/netzke/composition.rb, line 96
def registered_components
  read_inheritable_attribute(:components) || []
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.