Module: Noodles

Defined in:
lib/noodles.rb,
lib/noodles/cache.rb,
lib/noodles/utils.rb,
lib/noodles/version.rb,
lib/noodles/http/view.rb,
lib/noodles/application.rb,
lib/noodles/environment.rb,
lib/noodles/http/router.rb,
lib/noodles/sessionable.rb,
lib/noodles/http/controller.rb,
lib/noodles/http/application.rb,
lib/noodles/memcached_session.rb,
lib/noodles/websocket/channel.rb,
lib/noodles/websocket/handler.rb,
lib/noodles/websocket/routing.rb,
lib/noodles/websocket/application.rb,
lib/noodles/http/errors/no_router_error.rb

Defined Under Namespace

Modules: Environment, Http, Sessionable, Websocket Classes: Application, Cache, MemcachedSession

Constant Summary collapse

VERSION =
"0.0.8"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cache_store_nameObject

Returns the value of attribute cache_store_name.



51
52
53
# File 'lib/noodles.rb', line 51

def cache_store_name
  @cache_store_name
end

.use_memached_as_session_storageObject

Returns the value of attribute use_memached_as_session_storage.



51
52
53
# File 'lib/noodles.rb', line 51

def use_memached_as_session_storage
  @use_memached_as_session_storage
end

Class Method Details

.applicationObject



15
16
17
18
# File 'lib/noodles.rb', line 15

def application
  return @@application if defined? @@application
  @@application = Noodles::Application.new
end

.cacheObject



40
41
42
43
44
45
# File 'lib/noodles.rb', line 40

def cache
 return @@cache if defined? @@cache
 namespace = cache_store_name || 'noodle_app'
 options = { namespace: namespace, compress: true }
 @@cache = Cache.new('localhost:11211', options)
end

.envObject



11
12
13
# File 'lib/noodles.rb', line 11

def env
  Environment
end

.http_appObject



20
21
22
23
# File 'lib/noodles.rb', line 20

def http_app
  return @@http_app if defined? @@http_app
  @@http_app = application.http_app
end

.secretsObject



30
31
32
33
34
# File 'lib/noodles.rb', line 30

def secrets
  rendered_string = Erubis::Eruby.new(File.read(secrets_path)).result
  secrets_hash = YAML.load(rendered_string)[Noodles.env.to_s]
  OpenStruct.new(secrets_hash)
end

.secrets_pathObject



36
37
38
# File 'lib/noodles.rb', line 36

def secrets_path
  File.join('config', 'secrets.yml')
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Noodles)

    the object that the method was called on



47
48
49
# File 'lib/noodles.rb', line 47

def setup
  yield self
end

.to_underscore(string) ⇒ Object



2
3
4
5
6
7
# File 'lib/noodles/utils.rb', line 2

def self.to_underscore(string)
  string.gsub(/::/, '/').
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
  tr("-", "_").downcase
end

.websocket_appObject



25
26
27
28
# File 'lib/noodles.rb', line 25

def websocket_app
  return @@websocket_app if defined? @@websocket_app
  @@websocket_app = application.websocket_app
end