Guest User

Untitled

a guest
Apr 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. class SomeDSLFacadeObject
  2. def self.some_dsl_method(&block)
  3. self.instance_eval &block
  4. end
  5.  
  6. def self.dsl_verb(arg)
  7. puts "my arg is #{arg.inspect}"
  8. end
  9. end
  10.  
  11. class A
  12. def nondsl_argument
  13. 'from method'
  14. end
  15.  
  16. def do_stuff
  17. SomeDSLFacadeObject.some_dsl_method do
  18. dsl_verb nondsl_argument
  19. end
  20. end
  21. end
  22.  
  23.  
  24. class B
  25.  
  26. def do_stuff
  27. @nondsl_argument = 'from attr'
  28. SomeDSLFacadeObject.some_dsl_method do
  29. dsl_verb @nondsl_argument
  30. end
  31. end
  32. end
  33.  
  34. class D
  35.  
  36. def do_stuff
  37. nondsl_argument = 'from local'
  38. SomeDSLFacadeObject.some_dsl_method do
  39. dsl_verb nondsl_argument
  40. end
  41. end
  42. end
  43.  
  44.  
  45.  
  46. A.new.do_stuff
  47. B.new.do_stuff
  48. D.new.do_stuff
Add Comment
Please, Sign In to add comment