Class: Duse::Client::Namespace
- Inherits:
-
Module
- Object
- Module
- Duse::Client::Namespace
- Defined in:
- lib/duse/client/namespace.rb
Defined Under Namespace
Classes: Curry
Instance Attribute Summary collapse
-
#session ⇒ Object
Returns the value of attribute session.
Instance Method Summary collapse
- #get_curry_extension(name) ⇒ Object
- #included(klass) ⇒ Object
-
#initialize ⇒ Namespace
constructor
A new instance of Namespace.
Constructor Details
#initialize ⇒ Namespace
Returns a new instance of Namespace.
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/duse/client/namespace.rb', line 84 def initialize @session = Session.new Entity.subclasses.each do |subclass| name = subclass.name[/[^:]+$/] curry = Curry.new(self, subclass) curry_extension = get_curry_extension(name) curry.extend curry_extension if curry_extension const_set(name, curry) end end |
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session.
82 83 84 |
# File 'lib/duse/client/namespace.rb', line 82 def session @session end |
Instance Method Details
#get_curry_extension(name) ⇒ Object
96 97 98 99 100 |
# File 'lib/duse/client/namespace.rb', line 96 def get_curry_extension(name) Curry.const_get(name) rescue NameError nil end |
#included(klass) ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'lib/duse/client/namespace.rb', line 102 def included(klass) return if klass == Object or klass == Kernel namespace = self klass.define_singleton_method(:session) { namespace.session } klass.define_singleton_method(:session=) { |value| namespace.session = value } klass.define_singleton_method(:config) { session.config } klass.define_singleton_method(:config=) { |value| session.config = value } end |