require 'fedux_org/stdlib/models/base_model' module FeduxOrg module Stdlib module Models # model for import action module FilesystemBasedModel def self.included(base) base.extend ClassMethods end module ClassMethods #initialize model def init load_from_filesystem end private def module_name name = fqcn name.pop name.join('::') end def fqcn self.to_s.split(/::/) end def model_name fqcn.last end def library_name fqcn.first end def suffix raise FeduxOrg::Stdlib::Models::Exceptions::MethodNeedsToBeImplemented, "Please defined the method \"suffix\" to make the library work." end def path raise FeduxOrg::Stdlib::Models::Exceptions::MethodNeedsToBeImplemented, "Please defined the method \"path\" to make the library work." end def path_to_instances local_path = ::File.expand_path("../../#{model_name.pluralize.underscore}", path ) ::File.join(local_path,"*#{suffix}") end def name(path) name = File.basename(path, suffix ).to_sym raise FeduxOrg::Stdlib::Models::Exceptions::UnauthorizedUseOfKeyword if forbidden_keywords.include? name name end def load_from_filesystem raise FeduxOrg::Stdlib::Models::Exceptions::MethodNeedsToBeImplemented end def forbidden_keywords [ ] end end end end end end