module Smooth
The Smooth
API
An API is a collection of resources. A Resource
is a collection of data models, and the API allows us to run queries against those data models or to run commands that express an intent to mutate the data models.
An API provides different methods of authentication, and different policies for authorizations.
An API is very easy to put a rest interface in front of, but can also work in other scenarios that speak JSON since the interface pretty well encapsulates the behavior.
Internal class to provide current user awareness to the
The Smooth::Event::Relay
listens for events on any Smooth::Event
notifications channel It takes the event, performs some optional processing on it, and then relays information about that event to some other service. For example, a websocket or another event tracking api.
Constants
- VERSION
Public Class Methods
# File lib/smooth.rb, line 148 def self.active_record Smooth::AR::Adapter end
# File lib/smooth.rb, line 132 def self.app @application || fail('Application not initialized') end
# File lib/smooth.rb, line 136 def self.application(options = {}, &block) @application ||= Smooth::Application.new(options, &block) end
# File lib/smooth/cache.rb, line 4 def self.cache Smooth::Cache.instance end
Returns a reference to the base Command
class
# File lib/smooth.rb, line 71 def self.command config.command_class end
# 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
# File lib/smooth.rb, line 160 def self.developer_tools_root gem_root.join('..', 'developer-tools') end
# 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
# File lib/smooth.rb, line 152 def self.env ENV['SMOOTH_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development' end
# File lib/smooth.rb, line 118 def self.events Smooth::Event::Proxy end
Gets the faker generator for a given data type.
# 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.
# File lib/smooth.rb, line 87 def self.fakers @fakers ||= Smooth::Resource::Templating.fakers end
# File lib/smooth.rb, line 156 def self.gem_root Pathname(File.dirname(__FILE__)) end
# File lib/smooth.rb, line 144 def self.models_path config.models_path end
Returns a reference to the base Query
class
# File lib/smooth.rb, line 76 def self.query config.query_class end
# File lib/smooth.rb, line 140 def self.root Smooth.config.root end
Returns a reference to the base Serializer
class
# File lib/smooth.rb, line 81 def self.serializer config.serializer_class end
# File lib/smooth.rb, line 107 def self.util Smooth::Util end