Module: Netzke::Core::Actions::ClassMethods

Defined in:
lib/netzke/core/actions.rb

Instance Method Summary collapse

Instance Method Details

#action(*args, &block) ⇒ Object

Declares an action



119
120
121
122
123
124
125
126
127
# File 'lib/netzke/core/actions.rb', line 119

def action(*args, &block)
  args.each{|name| action(name)} if args.length > 1

  name = args.first

  define_method :"#{name}_action", &(block || ->(c){c})
  # NOTE: "<<" won't work here as this will mutate the array shared between classes
  self._declared_actions += [name]
end

#uri_to_icon(icon) ⇒ String|nil

NOTE: must stay public, used from ActionConfig

Returns:

  • (String|nil)

    full URI to an icon file by its name (provided we have a controller)



131
132
133
# File 'lib/netzke/core/actions.rb', line 131

def uri_to_icon(icon)
  Netzke::Core.with_icons ? [(controller && controller.config.relative_url_root), Netzke::Core.icons_uri, '/', icon.to_s, ".png"].join : nil
end