Class: RailsFeatureFlip::Generators::FeatureGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/rails_feature_flip/feature/feature_generator.rb

Overview

Generates a feature file under config/features to configure a feature of the app

Instance Method Summary collapse

Instance Method Details

#generate_feature ⇒ Object

Generate a feature



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/rails_feature_flip/feature/feature_generator.rb', line 18

def generate_feature
  @name = name.underscore.downcase
  parts = class_name.split('::')
  @namespace_parts = parts[0..-2]
  @feature_class_name = "#{parts.last}Feature"
  @attributes = prepend_enabled_attribute(attributes)
  @boolean_attributes = @attributes.select { |attr| attr.type == :boolean }
  @defaults = options[:defaults]

  template('feature.erb', "config/features/#{@name}_feature.rb")
end