Sha256: 1beea2960dc28040251092a9ea5ec8ea0fed0abf5dc1046c027b18281775c264
Contents?: true
Size: 885 Bytes
Versions: 1
Compression:
Stored size: 885 Bytes
Contents
require 'multi_json' module Rhino module Model class FileModel def initialize(file_name) @file_name = file_name base_name = File.split(file_name)[-1] @id = File.basename(base_name, ".json").to_i obj = File.read(file_name) @hash = MultiJson.load(obj) end def [](name) @hash[name.to_s] end def []=(name, value) @hash[name.to_s] = value end def self.find(id) FileModel.new("db/quotes/#{id}.json") rescue nil end def self.all files = Dir['db/quotes/*.json'] files.map{|f| FileModel.new f}.select{|x| !x.nil? } end # TODO def self.find_by_committer(committer) end # TODO def self.where(options={}) end # TODO def update_attribute(options={}) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rhino-framework-0.1.1 | lib/rhino/file_model.rb |