Sha256: 439c00b925e4a774b8469fe78ce48fb92b0b63f207ae9c0343a22b455011de35
Contents?: true
Size: 697 Bytes
Versions: 1
Compression:
Stored size: 697 Bytes
Contents
require 'forwardable' module Bogus class ActiveRecordAccessors extend Takes extend Forwardable takes :klass, :instance_methods def_delegators :instance_methods, :remove, :define def all return [] unless klass < ActiveRecord::Base return missing_attributes end def get(name) Attribute.new(name) end private def instance_methods @instance_methods.call(klass) end def all_attributes klass.columns.map(&:name).map(&:to_sym) end def missing_attributes all_attributes - instance_methods.all end class Attribute < Struct.new(:name) def parameters [] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bogus-0.1.0 | lib/bogus/active_record_accessors.rb |