class Mongoid::Generators::RemexifyGenerator
Public Instance Methods
generate_log_model()
click to toggle source
# File lib/generators/mongoid/remexify_generator.rb, line 8 def generate_log_model Rails::Generators.invoke "mongoid:model", [name] end
generate_logowner_model()
click to toggle source
# File lib/generators/mongoid/remexify_generator.rb, line 12 def generate_logowner_model Rails::Generators.invoke "mongoid:model", ["#{name}Owners"] end
inject_log_model()
click to toggle source
# File lib/generators/mongoid/remexify_generator.rb, line 16 def inject_log_model log_data = <<RUBY include Mongoid::Timestamps::Short # 0; the more high the level, the more important field :level, type: Integer, default: 0 # let your log be unique field :md5, type: String field :message, type: String field :backtrace, type: String field :file_name, type: String field :class_name, type: String field :method_name, type: String field :line, type: String # additional parameters that want to be logged as well field :parameters, type: String # additional description that want to be logged as well field :description, type: String # how many times the system logging this error? field :frequency, type: Integer, default: 1 validates_presence_of :level, :md5, :message, :class_name, :frequency index({ md5: 1 }, {unique: true}) RUBY inject_into_file File.join("app", "models", "#{file_path}.rb"), log_data, after: "include Mongoid::Document\n" end
inject_logowner_model()
click to toggle source
# File lib/generators/mongoid/remexify_generator.rb, line 50 def inject_logowner_model log_data = <<RUBY include Mongoid::Timestamps::Short field :log_md5, type: String field :identifier_id, type: String field :param1, type: String field :param2, type: String field :param3, type: String validates_presence_of :log_md5, :identifier_id index({ md5: 1, identifier_id: 1 }, { unique: true }) RUBY inject_into_file File.join("app", "models", "#{file_path}_owners.rb"), log_data, after: "include Mongoid::Document\n" end
make_initializer()
click to toggle source
# File lib/generators/mongoid/remexify_generator.rb, line 68 def make_initializer template "initialize_remexify.rb", "config/initializers/00_remexify.rb" end