Sha256: e9b0767f414fe69838c4ac6f8034400aaa03e668ff2d8d7eecf9a15f5bec1fac
Contents?: true
Size: 1.24 KB
Versions: 30
Compression:
Stored size: 1.24 KB
Contents
class MnoEnterprise::DatabaseExtensionGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) argument :fields, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]" # Check the class we want to extend exists def check_class_exists klass = "MnoEnterprise::#{class_name}" klass.constantize rescue NameError raise Thor::Error, "The class '#{klass}' does not exist in Maestrano Enterprise" end def check_class_is_decorator_ready klass = "MnoEnterprise::Concerns::Models::#{class_name}" klass.constantize rescue NameError raise Thor::Error, "The class '#{class_name}' is not decorator ready. Please extract it to #{klass}." end # Check the class we want to extend doesn't exist def check_class_collision @model_name = "MnoEnterprise::#{class_name}Extension" @model_name.constantize rescue nil # To preload class in dev? class_collisions @model_name end def generate_extension_model params = "#{@model_name} #{file_name}_uid:string:uniq " + fields.join(' ') + " --no-fixture -t rspec" generate "model", params end def generate_mnoe_model template 'model.rb', File.join('app/models/mno_enterprise', "#{file_name}.rb") end end
Version data entries
30 entries across 30 versions & 1 rubygems