Module: Padrino::Module

Defined in:
padrino-core/lib/padrino-core/module.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#root(*args) ⇒ String

Helper method for file references within a Padrino module.

Examples:

module MyModule
  extend Padrino::Module
  gem! 'my_gem'
end
Module.root!


32
33
34
# File 'padrino-core/lib/padrino-core/module.rb', line 32

def root(*args)
  File.expand_path(File.join(@root, *args))
end

Instance Method Details

#dependency_pathsArray<String>

Returns the list of path globs to load as dependencies. Appends custom dependency patterns to the be loaded for Padrino.

Examples:

module MyModule
  extend Padrino::Module
  gem! 'my_gem'
end

Module.dependency_paths << "#{MyModule.root}/uploaders/*.rb"


51
52
53
54
55
56
# File 'padrino-core/lib/padrino-core/module.rb', line 51

def dependency_paths
  [
    "#{root}/lib/**/*.rb", "#{root}/shared/lib/**/*.rb",
    "#{root}/models/**/*.rb", "#{root}/shared/models/**/*.rb"
  ]
end

#gem!(name) ⇒ Object

Register this module as being loaded from a gem. This automatically sets the root and therefore the dependency paths correctly.



13
14
15
# File 'padrino-core/lib/padrino-core/module.rb', line 13

def gem!(name)
  self.root = Padrino.gem(name, self)
end