Sha256: 8c9f298e74b9bdd1713c652a098033724c0edfc148164fdc54a74d49b1eea7e7
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
require 'microscope/version' require 'ostruct' require 'active_record' require 'active_support' require 'microscope/utils' require 'microscope/scope' require 'microscope/scope/boolean_scope' require 'microscope/scope/datetime_scope' require 'microscope/scope/date_scope' require 'microscope/instance_method' require 'microscope/instance_method/boolean_instance_method' require 'microscope/instance_method/datetime_instance_method' require 'microscope/instance_method/date_instance_method' module Microscope # Constants BlacklistedColumnsErrorMessage = 'The `%s` column cannot be used with Microscope because it’s on ActiveRecord’s method name blacklist.'.freeze # Errors BlacklistedColumnsError = Class.new(StandardError) end module ActiveRecord class Base def self.acts_as_microscope(options = {}) return unless table_exists? except = options[:except] || [] model_columns = columns.dup.reject { |c| except.include?(c.name.to_sym) } if only = options[:only] model_columns = model_columns.select { |c| only.include?(c.name.to_sym) } end Microscope::Scope.inject_scopes(self, model_columns, options) Microscope::InstanceMethod.inject_instance_methods(self, model_columns, options) rescue ActiveRecord::ActiveRecordError nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
microscope-1.1.1 | lib/microscope.rb |