, , . " " , , DSL, , , . , , , .
Sinatra
sinatra/main.rb, , Sinatra::Delegator . .
,
delegate :get, :patch, :put, :post, :delete, :head, :options, :template, :layout,
:before, :after, :error, :not_found, :configure, :set, :mime_type,
:enable, :disable, :use, :development?, :test?, :production?,
:helpers, :settings
, ..
self.target = Application
respond_to? target, .
def self.delegate(*methods)
methods.each do |method_name|
define_method(method_name) do |*args, &block|
return super(*args, &block) if respond_to? method_name
Delegator.target.send(method_name, *args, &block)
end
private method_name
end
end
Cucumber > . ( , .. ) DSL. , DSL , , , " " . .
HAML
HAML, DSL, "", .. . ( ) haml case...
def process_line(text, index)
@index = index + 1
case text[0]
when DIV_CLASS; push div(text)
when DIV_ID
return push plain(text) if text[1] == ?{
push div(text)
when ELEMENT; push tag(text)
when COMMENT; push comment(text[1..-1].strip)
...
, , . plain
FYI .
ELEMENT = ?%
DIV_CLASS = ?.
DIV_ID = ?
COMMENT = ?/