Sha256: eea3a0b7683b781e5a3b657b1a6aa95caac078c2fa3e938406b903b60231b625
Contents?: true
Size: 1.1 KB
Versions: 5
Compression:
Stored size: 1.1 KB
Contents
module Neo4j module MetaModel module ModelBase extend ActiveSupport::Concern LOADED_CLASSES = [] included do |base| LOADED_CLASSES << self end module ClassMethods def inherited(base) LOADED_CLASSES << base end def meta_model_class name.gsub(/^Neo4j::MetaModel::/, '') end def naming_column # Probably want to allow the user to choose this column = (['name', 'title', 'description'] & attributes.keys).first column || Neo4j::MetaModel::Model.where(class_name: meta_model_class).first.properties.detect {|p| p.type == 'String' }.name end end def naming_column_value self.read_attribute(self.class.naming_column) end def meta_model_class self.class.meta_model_class end def association_values self.class.associations.each_with_object({}) do |(key, _), result| result[key] = self.send(key) end end def _description self.send(self.class.naming_column) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems