Module: Plug

Extended by:
Plug, Configuration
Included in:
Plug
Defined in:
lib/plug.rb,
lib/plug/engine.rb,
lib/plug/version.rb,
lib/plug/constraint.rb,
lib/plug/configuration.rb,
app/models/plug/feature.rb,
app/models/plug/site_notice.rb,
app/models/plug/resources/feature.rb,
app/models/plug/application_record.rb,
app/helpers/plug/application_helper.rb,
app/mailers/plug/application_mailer.rb,
app/models/plug/resources/site_notice.rb,
lib/generators/plug/install_generator.rb,
app/models/plug/concerns/model_helpers.rb,
app/controllers/plug/api/api_controller.rb,
app/controllers/plug/features_controller.rb,
app/services/plug/task_execution_service.rb,
app/controllers/plug/application_controller.rb,
app/controllers/plug/api/features_controller.rb,
app/controllers/plug/site_notices_controller.rb,
app/controllers/plug/api/site_notices_controller.rb

Defined Under Namespace

Modules: Api, ApplicationHelper, Concerns, Configuration, Resources Classes: ApplicationController, ApplicationMailer, ApplicationRecord, Constraint, Engine, Feature, FeaturesController, InstallGenerator, SiteNotice, SiteNoticesController, TaskExecutionService

Constant Summary collapse

VERSION =

Update version in package.json too

'0.2.0'

Constants included from Configuration

Configuration::ALLOW_DELETE, Configuration::AUTH_PASSWORD, Configuration::AUTH_USER, Configuration::VALID_OPTIONS_KEYS

Instance Method Summary collapse

Methods included from Configuration

configure, options

Instance Method Details

#enabled?(arg) ⇒ Boolean

enabled? returns true of false

Parameters:

  • arg (String, Symbol)

    The slug or name of the Feature

Returns:

  • (Boolean)

    true - Feature found and enabled | true - Feature not found (We don’t want to block) | false - Feature was set to disabled



16
17
18
19
20
# File 'lib/plug.rb', line 16

def enabled?(arg)
  get_feature(arg).enabled?
rescue StandardError
  true
end

#notice(arg, &block) ⇒ String

Returns the notice of a given Feature

Parameters:

  • arg (String)

    The slug or name of the Feature

  • &block (Proc)

    The block of HTML/String for the notice

Returns:

  • (String)

    The block of HTML/String with notice



28
29
30
31
32
33
34
# File 'lib/plug.rb', line 28

def notice(arg, &block)
  feature = get_feature(arg)

  render_notice(feature.notice, &block) unless feature.enabled? || feature.notice.blank?
rescue StandardError
  nil
end