Parent

Netzke::Base

The base for every Netzke component

Class-level configuration

You can configure component classes in Rails Application, e.g.:

config.netzke.basepack.grid_panel.column_filters_available = false

Optionally, when used outside of Rails, you can also set the values directly on Netzke::Core.config (the Engine does it for you):

Netzke::Core.config.netzke.basepack.grid_panel.column_filters_available = false

If both default and overriding values are hashes, the default value gets deep-merged with the overriding value.

Netzke::Base provides the following class-level configuration options:

Attributes

global_id[R]

Global id in the components tree, following the double-underscore notation, e.g. books__config_panel__form

name[R]

Name that the parent can reference us by. The last part of global_id

parent[R]

Parent component

Public Class Methods

constantize_class_name(class_name) click to toggle source

Component’s class, given its name. Note: this method will be memoized if Rails.configuration.cache_classes is true.

# File lib/netzke/base.rb, line 67
def constantize_class_name(class_name)
  "#{class_name}".constantize
rescue NameError
  begin
    "Netzke::#{class_name}".constantize
  rescue NameError
    nil
  end
end
i18n_id() click to toggle source

The ID used to locate this component’s block in locale files

# File lib/netzke/base.rb, line 85
def i18n_id
  name.split("::").map{|c| c.underscore}.join(".")
end
increase_total_instances() click to toggle source
# File lib/netzke/base.rb, line 139
def self.increase_total_instances
  @@instances ||= 0
  @@instances += 1
end
instance_by_config(config) click to toggle source

Instance of component by config

# File lib/netzke/base.rb, line 78
def instance_by_config(config)
  klass = config[:klass] || constantize_class_name(config[:class_name])
  raise NameError, "Netzke: Unknown component #{config[:class_name]}" if klass.nil?
  klass.new(config)
end
new(conf = {}, parent = nil) click to toggle source

Instantiates a component instance. A parent can optionally be provided.

# File lib/netzke/base.rb, line 92
def initialize(conf = {}, parent = nil)
  @passed_config = conf # configuration passed at the moment of instantiation
  @passed_config.deep_freeze
  @parent        = parent
  @name          = conf[:name].nil? ? short_component_class_name.underscore : conf[:name].to_s
  @global_id     = parent.nil? ? @name : "#{parent.global_id}__#{@name}"
  @flash         = []
  # initialize @components and @items
  normalize_components_in_items
  # auto_collect_actions_from_config_and_js_properties
  self.class.increase_total_instances
end
reset_total_instances() click to toggle source
# File lib/netzke/base.rb, line 135
def self.reset_total_instances
  @@instances = 0
end
short_component_class_name() click to toggle source

Component’s short class name, e.g.: “Netzke::Module::SomeComponent” => “Module::SomeComponent”

# File lib/netzke/base.rb, line 61
def short_component_class_name
  self.name.sub(/^Netzke::/, "")
end
total_instances() click to toggle source

Used for performance measurments

# File lib/netzke/base.rb, line 131
def self.total_instances
  @@instances || 0
end

Public Instance Methods

before_load() click to toggle source

Override this method to do stuff at the moment of first-time loading

# File lib/netzke/base.rb, line 118
def before_load
end
clean_up() click to toggle source
# File lib/netzke/base.rb, line 121
def clean_up
  component_session.clear
  components.keys.each { |k| component_instance(k).clean_up }
end
constantize_class_name(class_name) click to toggle source

Proxy to the equally named class method

# File lib/netzke/base.rb, line 108
def constantize_class_name(class_name)
  self.class.constantize_class_name(class_name)
end
i18n_id() click to toggle source
# File lib/netzke/base.rb, line 126
def i18n_id
  self.class.i18n_id
end
short_component_class_name() click to toggle source

Proxy to the equally named class method

# File lib/netzke/base.rb, line 113
def short_component_class_name
  self.class.short_component_class_name
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.