Module: Pakyow::Support::ObjectMaker Private
- Defined in:
- lib/pakyow/support/makeable/object_maker.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .define_const_for_object_with_name(object_to_define, object_name) ⇒ Object private
- .define_object_on_target_with_constant_name(object, target, constant_name) ⇒ Object private
Class Method Details
.define_const_for_object_with_name(object_to_define, object_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 12 13 14 15 16 17 |
# File 'lib/pakyow/support/makeable/object_maker.rb', line 9 def self.define_const_for_object_with_name(object_to_define, object_name) return if object_name.nil? target = object_name.namespace.parts.inject(Object) { |target_for_part, object_name_part| ObjectMaker.define_object_on_target_with_constant_name(Module.new, target_for_part, object_name_part) } ObjectMaker.define_object_on_target_with_constant_name(object_to_define, target, object_name.name) end |
.define_object_on_target_with_constant_name(object, target, constant_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 24 25 26 27 |
# File 'lib/pakyow/support/makeable/object_maker.rb', line 19 def self.define_object_on_target_with_constant_name(object, target, constant_name) constant_name = Support.inflector.camelize(constant_name) unless target.const_defined?(constant_name, false) target.const_set(constant_name, object) end target.const_get(constant_name) end |