Module: GirFFI::BuilderHelper
- Included in:
- BaseTypeBuilder, Builder, GirFFI::Builders::ModuleBuilder
- Defined in:
- lib/gir_ffi/builder_helper.rb
Instance Method Summary collapse
- #get_or_define_class(namespace, name, parent) ⇒ Object
- #get_or_define_module(parent, name) ⇒ Object
- #optionally_define_constant(parent, name) ⇒ Object
Instance Method Details
#get_or_define_class(namespace, name, parent) ⇒ Object
11 12 13 |
# File 'lib/gir_ffi/builder_helper.rb', line 11 def get_or_define_class namespace, name, parent optionally_define_constant(namespace, name) { Class.new parent } end |
#get_or_define_module(parent, name) ⇒ Object
15 16 17 |
# File 'lib/gir_ffi/builder_helper.rb', line 15 def get_or_define_module parent, name optionally_define_constant(parent, name) { Module.new } end |
#optionally_define_constant(parent, name) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/gir_ffi/builder_helper.rb', line 3 def optionally_define_constant parent, name if parent.const_defined? name, false parent.const_get name else parent.const_set name, yield end end |