Module: IncludableWithOptions
- Defined in:
- lib/dolzenko/includable_with_options.rb
Overview
Check Thomas Sawyer take on the problem github.com/rubyworks/paramix
Class Attribute Summary collapse
-
.last_default_options ⇒ Object
Returns the value of attribute last_default_options.
Class Method Summary collapse
Class Attribute Details
.last_default_options ⇒ Object
Returns the value of attribute last_default_options.
4 5 6 |
# File 'lib/dolzenko/includable_with_options.rb', line 4 def @last_default_options end |
Class Method Details
.included(includable_with_options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dolzenko/includable_with_options.rb', line 7 def self.included() %w(string/methodize kernel/constant module/basename module/spacename).each { |facets_core_ext| require "facets/#{ facets_core_ext }" } raise "IncludableWithOptions should be included by the Module" unless .instance_of?(Module) = "@@#{ .basename.methodize }_options" unless IncludableWithOptions..nil? .send(:class_variable_set, , IncludableWithOptions.) IncludableWithOptions. = nil end context = Kernel.constant(.spacename) option_setting_duplicator = <<-CODE def #{ context != Kernel ? "self." : "" }#{ .basename }(options = nil) m = Kernel.constant("#{ .name }").dup m.send(:class_variable_set, "#{ }", options) m end CODE context.module_eval(option_setting_duplicator) end |