Module: Lincoln::AttrIgnore::ClassMethods
- Defined in:
- lib/lincoln/attr_ignore.rb
Instance Method Summary collapse
-
#attr_ignore(*attributes) ⇒ Object
Attributes listed as ignore will be completely hidden from active record.
-
#columns_without_attr_ignore ⇒ Object
Return the list of columns taking into account the attr_ignore attribute.
-
#ignore_attributes ⇒ Object
Returns an array of all the attributes that have been specified as ignore.
Instance Method Details
#attr_ignore(*attributes) ⇒ Object
Attributes listed as ignore will be completely hidden from active record. They will not show up in create, update, delete, or queries. Read and write methods will not be generated as well.
17 18 19 |
# File 'lib/lincoln/attr_ignore.rb', line 17 def attr_ignore(*attributes) write_inheritable_attribute(:attr_ignore, Set.new(attributes.map { |a| a.to_s }) + (ignore_attributes || [])) end |
#columns_without_attr_ignore ⇒ Object
Return the list of columns taking into account the attr_ignore attribute.
27 28 29 30 31 32 33 34 |
# File 'lib/lincoln/attr_ignore.rb', line 27 def columns_without_attr_ignore unless defined?(@columns) && @columns @columns = columns_with_attr_ignore @columns.reject! { |column| ignore_attributes.include?(column.name) } end @columns end |
#ignore_attributes ⇒ Object
Returns an array of all the attributes that have been specified as ignore.
22 23 24 |
# File 'lib/lincoln/attr_ignore.rb', line 22 def ignore_attributes read_inheritable_attribute(:attr_ignore) || [] end |