Class: Smooth::Application
Defined Under Namespace
Classes: User
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #api ⇒ Object
- #boot ⇒ Object
- #command(*args) ⇒ Object
- #config(&block) ⇒ Object
- #console ⇒ Object
-
#initialize(options = {}, &block) ⇒ Application
constructor
A new instance of Application.
- #load_models ⇒ Object
- #query(*args) ⇒ Object
- #resource(*args, &_block) ⇒ Object
- #smooth ⇒ Object
- #system_user ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Application
Returns a new instance of Application.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/smooth/application.rb', line 8 def initialize( = {}, &block) @options = instance_eval(&block) if block_given? config do self.root = [:root] end boot unless [:defer] end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/smooth/application.rb', line 3 def @options end |
Instance Method Details
#api ⇒ Object
32 33 34 |
# File 'lib/smooth/application.rb', line 32 def api @api ||= Smooth([:api] || :default) end |
#boot ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/smooth/application.rb', line 58 def boot @boot ||= begin Smooth.active_record.establish_connection load_models Smooth.eager_load_from_app_folders end end |
#command(*args) ⇒ Object
48 49 50 |
# File 'lib/smooth/application.rb', line 48 def command(*args) smooth.send(:run_command, *args) end |
#config(&block) ⇒ Object
19 20 21 |
# File 'lib/smooth/application.rb', line 19 def config(&block) Smooth.config(&block) end |
#console ⇒ Object
23 24 25 26 |
# File 'lib/smooth/application.rb', line 23 def console require 'pry' Pry.start(self, {}) end |
#load_models ⇒ Object
52 53 54 55 56 |
# File 'lib/smooth/application.rb', line 52 def load_models Dir[config.models_path.join('**/*.rb')].each do |f| require config.models_path.join(f) end end |
#query(*args) ⇒ Object
44 45 46 |
# File 'lib/smooth/application.rb', line 44 def query(*args) smooth.send(:query, *args) end |
#resource(*args, &_block) ⇒ Object
40 41 42 |
# File 'lib/smooth/application.rb', line 40 def resource(*args, &_block) api.send(:resource, *args) end |
#smooth ⇒ Object
36 37 38 |
# File 'lib/smooth/application.rb', line 36 def smooth @smooth ||= api.as(system_user) end |
#system_user ⇒ Object
28 29 30 |
# File 'lib/smooth/application.rb', line 28 def system_user @system_user ||= User.new(email: '[email protected]', role: 'system') end |