Class: Arrest::ScopedRoot

Inherits:
Object
  • Object
show all
Defined in:
lib/arrest/transport/scoped_root.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context = Arrest::RequestContext.new()) ⇒ ScopedRoot

Returns a new instance of ScopedRoot.



5
6
7
# File 'lib/arrest/transport/scoped_root.rb', line 5

def initialize(context = Arrest::RequestContext.new())
  @context = context
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



3
4
5
# File 'lib/arrest/transport/scoped_root.rb', line 3

def context
  @context
end

Class Method Details

.register_resource(clazz) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/arrest/transport/scoped_root.rb', line 9

def self.register_resource(clazz)
  @classes ||= {}
  @classes[clazz] = true
  class_name = ClassUtils.simple_name(clazz)
  send :define_method, class_name do ||
    clazz.mk_proxy(self)
  end
end

.registered_classesObject



18
19
20
21
# File 'lib/arrest/transport/scoped_root.rb', line 18

def self.registered_classes
  @classes ||= {}
  @classes.keys
end

Instance Method Details

#delete_allObject



23
24
25
26
27
28
29
30
31
# File 'lib/arrest/transport/scoped_root.rb', line 23

def delete_all
  self.class.registered_classes.each do |clazz|
    begin
      clazz.delete_all(@context)
    rescue
      puts "couldnt delete #{clazz.name}s"
    end
  end
end

#get_contextObject



33
34
35
# File 'lib/arrest/transport/scoped_root.rb', line 33

def get_context
  @context
end