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