Class: Mashfeed::Plugin::Base
- Inherits:
-
Object
- Object
- Mashfeed::Plugin::Base
- Defined in:
- lib/mashfeed/plugin.rb
Class Method Summary collapse
- .inheritable_accessor(*syms) ⇒ Object
-
.option(name, options = {}) ⇒ Object
set plugin’s option.
-
.options ⇒ Object
get this plugin options.
Instance Method Summary collapse
-
#execute(items = []) ⇒ Object
need override.
-
#initialize(params = {}) ⇒ Base
constructor
preset default options.
Constructor Details
#initialize(params = {}) ⇒ Base
preset default options
36 37 38 39 40 |
# File 'lib/mashfeed/plugin.rb', line 36 def initialize(params={}) @params = {} self.class..each_pair{|k, v| @params[k] = v[:default] } params.each_pair{|k, v| @params[k.to_s] = v } end |
Class Method Details
.inheritable_accessor(*syms) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mashfeed/plugin.rb', line 6 def self.inheritable_accessor(*syms) syms.each do |sym| class_eval <<-__EOM__ def self.#{sym}(#{sym}=nil) #{sym}.nil? ? read_inheritable_attribute(:#{sym}) : write_inheritable_attribute(:#{sym}, #{sym}) end def self.#{sym}=(#{sym}) write_inheritable_attribute(:#{sym}, #{sym}) end __EOM__ end end |
.option(name, options = {}) ⇒ Object
set plugin’s option
22 23 24 25 26 27 28 |
# File 'lib/mashfeed/plugin.rb', line 22 def self.option(name, ={}) write_inheritable_attribute(:options, self..merge(name.to_s => )) class_eval <<-__EOM__ def #{name}(val=nil); val.nil? ? @params["#{name}"] : @params["#{name}"]=val ;end def #{name}=(val); @params["#{name}"] = val;end __EOM__ end |
.options ⇒ Object
get this plugin options
31 32 33 |
# File 'lib/mashfeed/plugin.rb', line 31 def self. read_inheritable_attribute(:options) || {} end |
Instance Method Details
#execute(items = []) ⇒ Object
need override
43 44 45 |
# File 'lib/mashfeed/plugin.rb', line 43 def execute(items=[]) items end |