Module: Spider::WidgetPlugin::ModuleMethods

Defined in:
lib/spiderfw/widget/widget_plugin.rb

Instance Method Summary collapse

Instance Method Details

#controller_action?(method) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/spiderfw/widget/widget_plugin.rb', line 54

def controller_action?(method)
    @controller_actions && @controller_actions.include?(method)
end

#controller_actions(*methods) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/spiderfw/widget/widget_plugin.rb', line 46

def controller_actions(*methods)
    if (methods.length > 0)
        @controller_actions ||= []
        @controller_actions += methods
    end
    @controller_actions
end

#get_assetsObject



39
40
41
42
43
44
# File 'lib/spiderfw/widget/widget_plugin.rb', line 39

def get_assets
    path = overrides_path
    return open(path){ |f| Hpricot.XML(f) }.root.children_of_type('tpl:asset').map{ |el|
        Spider::Template.parse_asset_element(el)
    }
end

#get_overridesObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/spiderfw/widget/widget_plugin.rb', line 28

def get_overrides
    overrides = []
    path = overrides_path
    doc = open(path){ |f| Hpricot.XML(f) }
    doc.root.each_child do |child|
        next unless child.is_a?(Hpricot::Elem)
        overrides << child
    end
    return overrides
end

#overrides_pathObject



24
25
26
# File 'lib/spiderfw/widget/widget_plugin.rb', line 24

def overrides_path
    @path+'/'+Inflector.underscore(self.to_s.split('::')[-1])+'.shtml'
end

#plugin_for(widget, plugin_name) ⇒ Object



18
19
20
21
22
# File 'lib/spiderfw/widget/widget_plugin.rb', line 18

def plugin_for(widget, plugin_name)
    @plugin_name = plugin_name
    widget.add_plugin(plugin_name, self)
    @path = File.dirname(File.expand_path(caller[0].split(':')[0]))
end

#plugin_nameObject



14
15
16
# File 'lib/spiderfw/widget/widget_plugin.rb', line 14

def plugin_name
    @plugin_name
end