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) {|config| ... } ⇒ Feature

Create a block based feature.

Parameters:

  • name (String)

    Unique identifyer of feature.

Yield Parameters:

  • config (Configuration)

    The configuration object to manipulate.

Since:

  • 0.9



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

def initialize(name, &block)
  @name = 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

Instance Method Details

#enable(config) ⇒ Object

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

Parameters:

Since:

  • 0.9



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

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

#name_translation_keyObject

Since:

  • 0.9



29
30
31
# File 'lib/pageflow/feature.rb', line 29

def name_translation_key
  "pageflow.#{name}.feature_name"
end