Sha256: 08c676823b8bef460ae181d5965677014f05009f05e8958eadf33ad05e3f1277
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
namespace :curupira do namespace :db do desc "Generate the records of the features" task :generate_features => :environment do Rails.application.eager_load! def eval_curupira_action(controller, action) feature_desc = case action.to_s when "index", "show", "search" I18n.t("curupira.features.#{controller}.show") when "create", "new" I18n.t("curupira.features.#{controller}.create") when "edit", "update" I18n.t("curupira.features.#{controller}.edit") when "delete", "destroy" I18n.t("curupira.features.#{controller}.delete") else "Other: " << action.to_s end end Curupira::AuthorizedController.subclasses.each do |controller| clazz = controller.to_s.underscore.gsub("_controller", "") feature = Feature.create name: I18n.t("curupira.features.#{clazz}.manage"), controller: clazz feature.action_labels << ActionLabel.create(name: "manage") controller.action_methods.each do |action| feature_description = eval_curupira_action(clazz, action) feature = Feature.find_by(name: feature_description) if feature.present? feature.action_labels << ActionLabel.create(name: action) else feature = Feature.create name: feature_description, controller: clazz feature.action_labels << ActionLabel.create(name: action) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
curupira-0.1.7 | lib/tasks/generate_features.rake |
curupira-0.1.6 | lib/tasks/generate_features.rake |
curupira-0.1.4 | lib/tasks/generate_features.rake |