Module: Smooth
- Extended by:
- Api::Tracking, DslAdapter, Event::Adapter, Resource::Tracking
- Defined in:
- lib/smooth/api.rb,
lib/smooth.rb,
lib/smooth/util.rb,
lib/smooth/cache.rb,
lib/smooth/event.rb,
lib/smooth/query.rb,
lib/smooth/example.rb,
lib/smooth/version.rb,
lib/smooth/resource.rb,
lib/smooth/response.rb,
lib/smooth/api/policy.rb,
lib/smooth/serializer.rb,
lib/smooth/application.rb,
lib/smooth/dsl_adapter.rb,
lib/smooth/event/relay.rb,
lib/smooth/api/tracking.rb,
lib/smooth/user_adapter.rb,
lib/smooth/configuration.rb,
lib/smooth/documentation.rb,
lib/smooth/model_adapter.rb,
lib/smooth/resource/router.rb,
lib/smooth/command/run_proxy.rb,
lib/smooth/resource/tracking.rb,
lib/smooth/resource/templating.rb,
lib/smooth/command/async_worker.rb,
lib/smooth/command/instrumented.rb,
lib/smooth/active_record/adapter.rb
Overview
Internal class to provide current user awareness to the
Defined Under Namespace
Modules: AR, Documentation, DslAdapter, ModelAdapter, UserAdapter, Util
Classes: Api, Application, ArraySerializer, Cache, Command, Configuration, DslProxy, Engine, ErrorResponse, Event, Example, Middleware, Query, Resource, Response, Serializer
Constant Summary
collapse
- VERSION =
'2.0.2'
Class Method Summary
collapse
apis, current_api, current_api_name, current_api_name=, fetch_api
current_resource, current_resource=, resources
subscribe_to, track_event
Methods included from DslAdapter
api, resource
Class Method Details
.active_record ⇒ Object
148
149
150
|
# File 'lib/smooth.rb', line 148
def self.active_record
Smooth::AR::Adapter
end
|
132
133
134
|
# File 'lib/smooth.rb', line 132
def self.app
@application || fail('Application not initialized')
end
|
.application(options = {}, &block) ⇒ Object
136
137
138
|
# File 'lib/smooth.rb', line 136
def self.application(options = {}, &block)
@application ||= Smooth::Application.new(options, &block)
end
|
4
5
6
|
# File 'lib/smooth/cache.rb', line 4
def self.cache
Smooth::Cache.instance
end
|
Returns a reference to the base Command class
71
72
73
|
# File 'lib/smooth.rb', line 71
def self.command
config.command_class
end
|
.config(&block) ⇒ Object
111
112
113
114
115
116
|
# File 'lib/smooth.rb', line 111
def self.config(&block)
block_given = block_given?
Smooth::Configuration.instance.tap do |cfg|
cfg.instance_eval(&block) if block_given
end
end
|
160
161
162
|
# File 'lib/smooth.rb', line 160
def self.developer_tools_root
gem_root.join('..', 'developer-tools')
end
|
.eager_load_from_app_folders ⇒ Object
122
123
124
125
126
127
128
129
130
|
# File 'lib/smooth.rb', line 122
def self.eager_load_from_app_folders
return unless config.eager_load_app_folders
config.app_folder_paths.each do |folder|
next unless folder.exist?
folder.children.select { |p| p.extname == '.rb' }.each { |f| require(f) }
end
end
|
152
153
154
|
# File 'lib/smooth.rb', line 152
def self.env
ENV['SMOOTH_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
end
|
118
119
120
|
# File 'lib/smooth.rb', line 118
def self.events
Smooth::Event::Proxy
end
|
.faker(token, force_string = true) ⇒ Object
Gets the faker generator for a given data type.
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/smooth.rb', line 92
def self.faker(token, force_string = true)
group, meth = token.split('.')
group = group.camelize.to_sym
value = begin
Faker.const_get(group).send(meth)
rescue
Faker::Company.catch_phrase
end
value = value.join("\n") if value.is_a?(Array) && force_string
value
end
|
Fakers can be used to generate fake API data, in our automated tests and in our documentation for example.
156
157
158
|
# File 'lib/smooth.rb', line 156
def self.gem_root
Pathname(File.dirname(__FILE__))
end
|
.models_path ⇒ Object
144
145
146
|
# File 'lib/smooth.rb', line 144
def self.models_path
config.models_path
end
|
Returns a reference to the base Query class
76
77
78
|
# File 'lib/smooth.rb', line 76
def self.query
config.query_class
end
|
140
141
142
|
# File 'lib/smooth.rb', line 140
def self.root
Smooth.config.root
end
|
.serializer ⇒ Object
Returns a reference to the base Serializer class
81
82
83
|
# File 'lib/smooth.rb', line 81
def self.serializer
config.serializer_class
end
|
107
108
109
|
# File 'lib/smooth.rb', line 107
def self.util
Smooth::Util
end
|