diff options
author | Altech <takeno.sh@gmail.com> | 2017-10-19 16:30:31 +0900 |
---|---|---|
committer | Altech <takeno.sh@gmail.com> | 2017-10-20 19:42:44 +0900 |
commit | e9f82e76e83497db094fe63104f548453fbe512e (patch) | |
tree | ffccdf95e5aa1069185cc1d810035862847b0b99 /activerecord/lib | |
parent | b7bf70982395ee5fd2e89064f87f268eeddb9d6d (diff) | |
download | rails-e9f82e76e83497db094fe63104f548453fbe512e.tar.gz rails-e9f82e76e83497db094fe63104f548453fbe512e.tar.bz2 rails-e9f82e76e83497db094fe63104f548453fbe512e.zip |
Convert ignored_columns to a list of string
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/model_schema.rb | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 34c0ef4e75..bed9400f51 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -115,20 +115,6 @@ module ActiveRecord # If true, the default table name for a Product class will be "products". If false, it would just be "product". # See table_name for the full rules on table/class naming. This is true, by default. - ## - # :singleton-method: ignored_columns - # :call-seq: ignored_columns - # - # The list of columns names the model should ignore. Ignored columns won't have attribute - # accessors defined, and won't be referenced in SQL queries. - - ## - # :singleton-method: ignored_columns= - # :call-seq: ignored_columns=(columns) - # - # Sets the columns names the model should ignore. Ignored columns won't have attribute - # accessors defined, and won't be referenced in SQL queries. - included do mattr_accessor :primary_key_prefix_type, instance_writer: false @@ -138,9 +124,9 @@ module ActiveRecord class_attribute :internal_metadata_table_name, instance_accessor: false, default: "ar_internal_metadata" class_attribute :protected_environments, instance_accessor: false, default: [ "production" ] class_attribute :pluralize_table_names, instance_writer: false, default: true - class_attribute :ignored_columns, instance_accessor: false, default: [].freeze self.inheritance_column = "type" + self.ignored_columns = [].freeze delegate :type_for_attribute, to: :class @@ -271,6 +257,22 @@ module ActiveRecord @explicit_inheritance_column = true end + # The list of columns names the model should ignore. Ignored columns won't have attribute + # accessors defined, and won't be referenced in SQL queries. + def ignored_columns + if defined?(@ignored_columns) + @ignored_columns + else + superclass.ignored_columns + end + end + + # Sets the columns names the model should ignore. Ignored columns won't have attribute + # accessors defined, and won't be referenced in SQL queries. + def ignored_columns=(columns) + @ignored_columns = columns.map(&:to_s) + end + def sequence_name if base_class == self @sequence_name ||= reset_sequence_name |