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_featureObject

Generate a feature



12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/rails_feature_flip/feature/feature_generator.rb', line 12

def generate_feature
  @name = name.underscore.downcase
  @klass_name = class_name
  @attributes = attributes
  @boolean_attributes = @attributes.collect { |attr| attr if attr.type == :boolean }.compact
  feature_file_path = Rails.root.join('config', 'features')
  feature_path = feature_file_path.join("#{@name}_feature.rb")

  template('feature.erb', feature_path)
end