lib/ronin/model/cacheable/cacheable.rb in ronin-1.0.0.rc3 vs lib/ronin/model/cacheable/cacheable.rb in ronin-1.0.0
- old
+ new
@@ -19,11 +19,11 @@
require 'ronin/model/cacheable/class_methods'
require 'ronin/model/model'
require 'ronin/cached_file'
-require 'contextify'
+require 'object_loader'
require 'set'
module Ronin
module Model
#
@@ -36,22 +36,16 @@
# {Database}, and a fresh copy of the object can be loaded from the
# file it was originally cached from.
#
# # Making a Model cacheable
#
- # In order to make a Model cacheable, one must include the {Cacheable}
- # module and contextifying the model. Contextifying a model involves
- # calling the `contextify` method, which defines a top-level method
- # used for loading model instances from files.
+ # In order to make a Model cacheable, one must include the {Cacheable}.
#
# class MyModel
#
# include Ronin::Model::Cacheable
#
- # # Defines the my_model method for loading instances from files
- # contextify :my_model
- #
# # Primary key of the model
# property :id, Serial
#
# # Title of the model
# property :title, String
@@ -102,11 +96,11 @@
#
module Cacheable
@models = Set[]
def self.included(base)
- base.send :include, Contextify, Model
+ base.send :include, ObjectLoader, Model
base.send :extend, ClassMethods
base.module_eval do
# The class-name of the cached object
property :type, DataMapper::Property::Discriminator
@@ -149,10 +143,10 @@
#
# @since 1.0.0
#
def Cacheable.load_from(path)
path = File.expand_path(path)
- obj = Contextify.load_contexts(path).find do |obj|
+ obj = ObjectLoader.load_objects(path).find do |obj|
obj.class < Cacheable
end
unless obj
raise(RuntimeError,"No cacheable object defined in #{path.dump}")