module GIGO::ActiveRecord::Base

Public Instance Methods

after_initialize_gigoize_attributes() click to toggle source
# File lib/gigo/active_record/base.rb, line 32
def after_initialize_gigoize_attributes
  after_initialize :gigoize_attributes
  define_method :gigoize_attributes do
    self.class.const_get(:GIGOColumns).instance_methods.each { |name| self.send(name) }
  end
  private :gigoize_attributes
end
gigo_coder_for(klass) click to toggle source
# File lib/gigo/active_record/base.rb, line 40
def gigo_coder_for(klass)
  GigoCoder.new(klass)
end
gigo_column(*attrs) click to toggle source
# File lib/gigo/active_record/base.rb, line 4
      def gigo_column(*attrs)
        mod = begin
          if const_defined?(:GIGOColumns)
            const_get(:GIGOColumns)
          else
            m = const_set(:GIGOColumns, Module.new)
            include m
            m
          end
        end
        attrs.each do |attr|
          mod.module_eval <<-CODE, __FILE__, __LINE__
            def #{attr}
              begin
                GIGO.load(super)
              rescue NoMethodError, ActiveModel::MissingAttributeError
                nil
              end
            end
          CODE
        end
      end
gigo_columns(*excepts) click to toggle source
# File lib/gigo/active_record/base.rb, line 27
def gigo_columns(*excepts)
  cols = columns.select{ |c| c.type == :string || c.type == :text }.map{ |c| c.name.to_s } - excepts.map(&:to_s)
  gigo_column(*cols)
end