Last active
July 7, 2016 20:38
-
-
Save haileys/01bc7f1c677eb4cb5588 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "set" | |
module GitHub | |
module AttrIgnore | |
attr_reader :ignored_columns | |
def attr_ignore(*columns) | |
@ignored_columns ||= Set.new | |
@ignored_columns |= columns.map(&:to_s) | |
end | |
def columns | |
if ignored_columns | |
super.reject { |column| ignored_columns.include?(column.name) } | |
else | |
super | |
end | |
end | |
end | |
end | |
# use like: | |
# | |
# class Spline < ActiveRecord::Base | |
# extend GitHub::AttrIgnore | |
# attr_ignore :reticulator_id | |
# end | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment