Sha256: 170063d9f443473cbf6cae851ad2e80569d1a92588d065b8d38488270d753d8a
Contents?: true
Size: 1.12 KB
Versions: 4
Compression:
Stored size: 1.12 KB
Contents
module Carload class Dashboard class ModelSpec attr_accessor :default, :attributes, :index_page, :associated_models def initialize @default = false @attributes = ExtendedHash.new @index_page = ExtendedHash.new @index_page[:shows] = ExtendedHash.new @index_page[:searches] = ExtendedHash.new @associated_models = {} end end class << self def model name, &block if block_given? @@models ||= {} spec = ModelSpec.new yield spec @@models[name] = spec else @@models[name] end end def associate args model_a = args.keys.first model_b = args.values.first @@models[model_a].associated_models[model_b] = args[:choose_by] @@models[model_b].associated_models[model_a] = nil end def models @@models ||= {} end def default_model return @@default_model if defined? @@default_model @@models.each do |name, spec| return @@default_model = name if spec.default end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
carload-0.2.2 | lib/carload/dashboard.rb |
carload-0.2.1 | lib/carload/dashboard.rb |
carload-0.2.0 | lib/carload/dashboard.rb |
carload-0.1.0 | lib/carload/dashboard.rb |