Module: TextTube::Filterable
- Included in:
- Coderay, EmbeddingAudio, EmbeddingVideo, InsideBlock, LinkReffing, Spiffing
- Defined in:
- lib/texttube/filterable.rb
Overview
Add this to your filter module.
Instance Method Summary collapse
-
#filter_with(name) {|String, Hash| ... } ⇒ Object
Add a filter.
-
#filters ⇒ Array<Symbol>
See all current filters.
Instance Method Details
#filter_with(name) {|String, Hash| ... } ⇒ Object
Add a filter.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/texttube/filterable.rb', line 34 def filter_with name, &block name = name.to_sym filters << name unless filters.include? name define_method name do |current=self, =nil| if current.respond_to? :keys =current current=self end = [, @options, self.class.].find{|opts| !opts.nil? && opts.respond_to?(:keys) && !opts.empty? } || {} block.call current, [name] end end |
#filters ⇒ Array<Symbol>
See all current filters.
20 21 22 |
# File 'lib/texttube/filterable.rb', line 20 def filters @filters ||= [] end |