Class: LXL::EmptyNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/lxl.rb

Overview

Namespace lookup for constants and functions (minimal methods).

Direct Known Subclasses

Namespace

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

Class Method Details

.const_defined?(symbol) ⇒ Boolean

Ensure all constants are included (inherited, extended, included, etc).

Returns:

  • (Boolean)


478
479
480
# File 'lib/lxl.rb', line 478

def self.const_defined?(symbol) #:nodoc:
  constants.include?(symbol.to_s)
end

.deferred_classObject

Default deferred class.



493
494
495
# File 'lib/lxl.rb', line 493

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>


505
506
507
508
# File 'lib/lxl.rb', line 505

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]


518
519
520
521
# File 'lib/lxl.rb', line 518

def self.register_symbols(*symbols)
  symbols.collect! { |s| s.to_s.upcase.to_sym }
  symbols.each { |s| const_set(s, s) }
end