Class: Mack::Distributed::View

Inherits:
Object
  • Object
show all
Includes:
DRbUndumped, Singleton
Defined in:
lib/mack-distributed/views/view.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ref(app_name) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mack-distributed/views/view.rb', line 26

def ref(app_name)          
  begin
    obj = Mack::Distributed::Utils::Rinda.read(:space => app_name.to_sym, 
                                               :klass_def => :distributed_views)
    return obj
  rescue Rinda::RequestExpiredError => er
    Mack.logger.warn(er)
  end
  
  return nil
end

.registerObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/mack-distributed/views/view.rb', line 15

def register
  if configatron.mack.distributed.share_views
    raise Mack::Distributed::Errors::ApplicationNameUndefined.new if configatron.mack.distributed.app_name.nil?
    # Mack.logger.info "Registering Mack::Distributed::View for '#{app_config.mack.distributed_app_name}' with Rinda"
    
    Mack::Distributed::Utils::Rinda.register_or_renew(:space => configatron.mack.distributed.app_name.to_sym,
                                                      :klass_def => :distributed_views, 
                                                      :object => Mack::Distributed::View.instance)
  end
end

Instance Method Details

#get(resource) ⇒ Object



8
9
10
11
12
# File 'lib/mack-distributed/views/view.rb', line 8

def get(resource)
  path = File.join(Mack.root, resource)
  raw = Mack::Distributed::ViewCache.get(path)
  return raw
end