Class: Redactor::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/redactor/dsl.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(redactor) ⇒ DSL

Returns a new instance of DSL.



5
6
7
# File 'lib/redactor/dsl.rb', line 5

def initialize(redactor)
  @redactor = redactor
end

Instance Attribute Details

#redactorObject (readonly)

Returns the value of attribute redactor.



3
4
5
# File 'lib/redactor/dsl.rb', line 3

def redactor
  @redactor
end

Class Method Details

.run(redactor, block) ⇒ Object



14
15
16
# File 'lib/redactor/dsl.rb', line 14

def self.run(redactor, block)
  new(redactor).instance_eval(&block)
end

Instance Method Details

#rule(reason, regex = nil, &block) ⇒ Object



9
10
11
12
# File 'lib/redactor/dsl.rb', line 9

def rule(reason, regex = nil, &block)
  rule = Rule.new(reason, regex, &block)
  redactor.register_rule(rule)
end