I am trying to write a DSL
as follows:-
def method method_name, &block
#do somthing...
define_method method_name , &block
#do somthing...
dummy_method = instance_method method_name
#do sumthing...
dummy_method.bind(self).call
end
def option_hash_has key_name
if option_hash.has_key?
true
else
false
end
end
def option_hash key_name
option_hash[key_name]
end
now our DSL
code is as follows
method :method_1 do
if options_hash_has("XYZ")
system("echo 'option XYZ is set'")
else
sytem("echo 'option XYZ is not set'")
end
end
Now my requirement is to check syntax error of method block initially
and deferred the execution.
For example: if I write option_hash_hass
instead of
option_has_has
(in method_1 block), this would tell user when
dummy_method.bind(:self).call
would execute. But I want to make this
parsing is first step of method.
def method method_name &block
parse_block(&block) # with respect to current dsl
# do everything same as i mentioned
end
How could I implement this parse_block(&block)
?