Class: Pageflow::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/pageflow/feature.rb

Overview

Represents a set of configuration changes that can be performed based on account or entry feature flags.

Since:

  • 0.9

Direct Known Subclasses

PageTypeFeature

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, name_translation_key: nil) {|config| ... } ⇒ Feature

Create a block based feature.

Parameters:

  • name (String)

    Unique identifyer of feature.

  • name_translation_key (String) (defaults to: nil)

    Translation key to represent the feature in the UI.

Yield Parameters:

  • config (Configuration)

    The configuration object to manipulate.

Since:

  • 0.9



25
26
27
28
29
# File 'lib/pageflow/feature.rb', line 25

def initialize(name, name_translation_key: nil, &block)
  @name = name
  @name_translation_key = name_translation_key || "pageflow.#{name}.feature_name"
  @block = block
end

Instance Attribute Details

#nameString (readonly)

Unique identifyer of feature.

Returns:

  • (String)

Since:

  • 0.9



10
11
12
# File 'lib/pageflow/feature.rb', line 10

def name
  @name
end

#name_translation_keyString (readonly)

Translation key to represent the feature in the UI.

Returns:

  • (String)

Since:

  • 0.9



15
16
17
# File 'lib/pageflow/feature.rb', line 15

def name_translation_key
  @name_translation_key
end

Instance Method Details

#enable(config) ⇒ Object

Perform any configuration change that is needed to activate this feature.

Parameters:

Since:

  • 0.9



35
36
37
# File 'lib/pageflow/feature.rb', line 35

def enable(config)
  @block.call(config) if @block
end