Sha256: f6298b88359903cce3855de405c8beda3af9d590873bfa6cc5ba10f988eaf73c
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
module Trestle class Attribute attr_reader :admin, :name, :type def initialize(admin, name, type) @admin, @name, @type = admin, name.to_sym, type end def association? type == :association end def boolean? type == :boolean end def text? type == :text end def datetime? [:datetime, :time, :date].include?(type) end def primary_key? name.to_s == admin.model.primary_key end def inheritance_column? name.to_s == admin.model.inheritance_column end def counter_cache? name.to_s.end_with?("_count") end class Association < Attribute attr_reader :association_class def initialize(admin, name, association_class) super(admin, name, :association) @association_class = association_class end def association_name name.to_s.sub(/_id$/, "") end def association_admin Trestle.admins[association_class.name.underscore.pluralize] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
trestle-0.8.3 | lib/trestle/attribute.rb |
trestle-0.8.2 | lib/trestle/attribute.rb |
trestle-0.8.0 | lib/trestle/attribute.rb |