Sha256: 1d583b4c3d35296ae36f75aa5a78bf90127c24af09e73fdf036519903384e8c5
Contents?: true
Size: 574 Bytes
Versions: 2
Compression:
Stored size: 574 Bytes
Contents
module ActiveRecordYaml class Model extend ActiveModel::Naming def self.all items end def self.first items.first end def self.last items.last end def self.count items.length end def self.items data = File.read(data_filename) YAML.load(data).map { |x| OpenStruct.new(x) } end def self.data_filename data_dir.join("#{model_name.plural}.yml") end def self.data_dir dir = Rails.env == "test" ? "spec" : "config" Rails.root.join(dir, "data") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_record_yaml-0.1.2 | lib/active_record_yaml/model.rb |
active_record_yaml-0.1.1 | lib/active_record_yaml/model.rb |