Module: Fopost::Rails
- Defined in:
- lib/fopost/rails.rb,
lib/fopost/rails/engine.rb,
lib/fopost/rails/railtie.rb,
lib/fopost/rails/version.rb,
lib/fopost/rails/publish_job.rb,
lib/fopost/rails/configuration.rb,
lib/fopost/rails/application_job.rb,
lib/fopost/rails/create_post_job.rb,
lib/fopost/rails/webhook_signature.rb,
app/controllers/fopost/rails/webhooks_controller.rb
Defined Under Namespace
Modules: WebhookSignature Classes: ApplicationJob, Configuration, CreatePostJob, Engine, PublishJob, Railtie, WebhooksController
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
-
.client ⇒ Object
A memoized, configured Fopost::Client.
-
.client=(client) ⇒ Object
Swap in your own client — a stubbed transport in tests, say.
-
.config ⇒ Object
(also: configuration)
The settings object.
-
.configure {|config| ... } ⇒ Object
Fopost::Rails.configure do |c| c.api_key = ENV end.
-
.reset! ⇒ Object
Config and client back to their defaults.
-
.reset_client! ⇒ Object
Forget the memoized client, so the next call rebuilds it from config.
Class Method Details
.client ⇒ Object
A memoized, configured Fopost::Client. Safe to call from any thread.
48 49 50 |
# File 'lib/fopost/rails.rb', line 48 def client @client || @mutex.synchronize { @client ||= build_client } end |
.client=(client) ⇒ Object
Swap in your own client — a stubbed transport in tests, say.
53 54 55 |
# File 'lib/fopost/rails.rb', line 53 def client=(client) @mutex.synchronize { @client = client } end |
.config ⇒ Object Also known as: configuration
The settings object. Also reachable as config.fopost inside
config/application.rb and any Rails initializer.
33 34 35 |
# File 'lib/fopost/rails.rb', line 33 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
Fopost::Rails.configure do |c| c.api_key = ENV end
41 42 43 44 45 |
# File 'lib/fopost/rails.rb', line 41 def configure yield config reset_client! config end |
.reset! ⇒ Object
Config and client back to their defaults. Meant for test suites.
64 65 66 67 68 |
# File 'lib/fopost/rails.rb', line 64 def reset! reset_client! config.reset! nil end |
.reset_client! ⇒ Object
Forget the memoized client, so the next call rebuilds it from config.
58 59 60 61 |
# File 'lib/fopost/rails.rb', line 58 def reset_client! @mutex.synchronize { @client = nil } nil end |