Class: LXL::EmptyNamespace
- Inherits:
-
Object
- Object
- LXL::EmptyNamespace
- Defined in:
- lib/lxl.rb
Overview
Namespace lookup for constants and functions (minimal methods).
Direct Known Subclasses
Constant Summary collapse
- METHODS =
Preserved methods
['__id__', '__send__', 'constants', 'const_defined?', 'const_get', 'const_set', 'class', 'instance_methods', 'method', 'methods', 'respond_to?', 'to_s']
Class Method Summary collapse
-
.const_defined?(symbol) ⇒ Boolean
Ensure all constants are included (inherited, extended, included, etc).
-
.deferred_class ⇒ Object
Default deferred class.
-
.register_deferred(*symbols) ⇒ Object
Register lowercase methods which return a Deferred function call.
-
.register_symbols(*symbols) ⇒ Object
Register uppercase constants of the same name and value.
Class Method Details
.const_defined?(symbol) ⇒ Boolean
Ensure all constants are included (inherited, extended, included, etc).
505 506 507 |
# File 'lib/lxl.rb', line 505 def self.const_defined?(symbol) #:nodoc: constants.include?(symbol.to_s) end |
.deferred_class ⇒ Object
Default deferred class.
520 521 522 |
# File 'lib/lxl.rb', line 520 def self.deferred_class LXL::Deferred end |
.register_deferred(*symbols) ⇒ Object
Register lowercase methods which return a Deferred function call.
class MyNamespace < LXL::Namespace
register_deferred :foo
end
LXL.new(MyNamespace.new).eval('=FOO(1, "two", 3)')
# => <LXL::Deferred @args=[1, "two", 3] @symbol=:foo>
532 533 534 535 |
# File 'lib/lxl.rb', line 532 def self.register_deferred(*symbols) symbols.collect! { |s| s.to_s.downcase.to_sym } symbols.each { |s| define_method(s) { |*args| self.class.deferred_class.new(s, *args) } } end |
.register_symbols(*symbols) ⇒ Object
Register uppercase constants of the same name and value.
class MyNamespace < LXL::Namespace
register_symbols :foo, :bar
end
LXL.new(MyNamespace.new).eval('=LIST(FOO, BAR)')
# => [:FOO, :BAR]
545 546 547 548 |
# File 'lib/lxl.rb', line 545 def self.register_symbols(*symbols) symbols.collect! { |s| s.to_s.upcase.to_sym } symbols.each { |s| const_set(s, s) } end |