Class: Smooth::Configuration
- Inherits:
-
Object
show all
- Includes:
- Singleton
- Defined in:
- lib/smooth/configuration.rb
Constant Summary
collapse
- @@query_class =
Smooth::Query
- @@command_class =
Smooth::Command
- @@serializer_class =
defined?(ApplicationSerializer) ? ApplicationSerializer : Smooth::Serializer
- @@enable_events =
true
- @@eager_load_app_folders =
true
- @@models_path =
'app/models'
- @@object_path_separator =
'.'
- @@definition_folders =
%w(app/models app/apis app/queries app/commands app/serializers app/resources)
- @@include_root_in_json =
true
- @@enable_factories =
true
- @@active_record_config =
'config/database.yml'
- @@schema_file =
'db/schema.rb'
- @@migrations_path =
'db/migrate'
- @@root =
Dir.pwd
- @@auth_token_column =
:authentication_token
- @@async_provider =
Sidekiq::Worker
- @@memory_store =
Smooth.cache
- @@embed_relationships_as =
:ids
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
68
69
70
71
72
73
74
|
# File 'lib/smooth/configuration.rb', line 68
def method_missing(meth, *args, &block)
if meth.to_s.match(/(\w+)\?$/)
!!(send(Regexp.last_match[1], *args, &block)) if respond_to?(Regexp.last_match[1])
else
super
end
end
|
Class Method Details
.method_missing(meth, *args, &block) ⇒ Object
76
77
78
|
# File 'lib/smooth/configuration.rb', line 76
def self.method_missing(meth, *args, &block)
instance.send(meth, *args, &block)
end
|
Instance Method Details
#active_record ⇒ Object
45
46
47
48
49
50
|
# File 'lib/smooth/configuration.rb', line 45
def active_record
return active_record_config if active_record_config.is_a?(Hash)
file = root.join(active_record_config)
fail 'The config file does not exist at ' + file.to_s unless file.exist?
YAML.load(file.open).fetch(Smooth.env)
end
|
#app_folder_paths ⇒ Object
60
61
62
|
# File 'lib/smooth/configuration.rb', line 60
def app_folder_paths
Array(definition_folders).map { |f| root.join(f) }
end
|
#enable_event_tracking? ⇒ Boolean
52
53
54
|
# File 'lib/smooth/configuration.rb', line 52
def enable_event_tracking?
!!@@enable_events
end
|
#models_path ⇒ Object
64
65
66
|
# File 'lib/smooth/configuration.rb', line 64
def models_path
root.join(@@models_path)
end
|
56
57
58
|
# File 'lib/smooth/configuration.rb', line 56
def root
Pathname(@@root)
end
|