Method: FunctionObject::Macro#class_mixin
- Defined in:
- lib/function_object/macro.rb
#class_mixin ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/function_object/macro.rb', line 10 def class_mixin Module.new.tap do |mixin| arg_descs_with_defaults.each do |desc| mixin.module_eval do private define_method("_default_#{desc.name}", &desc.default) end end arg_descs.each do |desc| mixin.module_eval do attr_reader desc.name end end mixin.module_eval <<-RUBY, __FILE__, __LINE__ + 1 def initialize(#{arg_list_stmt}) #{ivar_assign_stmt} end RUBY end end |