Sha256: c3c589823c1b97db9053efd80b64071261d64f452bbb110acee974f0aa29c629

Contents?: true

Size: 782 Bytes

Versions: 2

Compression:

Stored size: 782 Bytes

Contents

module Neoon
  module Node

    module ClassMethods
      attr_reader :neo_model_config

      def neo_model_config
        @neo_model_config ||= Model::Config.new(self)
      end

      def neoon(opts = {})
        yield(neo_model_config) if block_given?

        opts.each do |key, value|
          raise "No such option #{key} for #{self.name} model" unless neo_model_config.respond_to?("#{key}=")
          neo_model_config.send("#{key}=", value)
        end
      end
    end

    def self.included(receiver)
      receiver.send :include, Model::Node
      receiver.extend         Model::Schema
      receiver.extend         ClassMethods

      receiver.after_save    :neo_save
      receiver.after_destroy :neo_destroy

      Neoon.config.models << receiver
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
neoon-0.0.5 lib/neoon/node.rb
neoon-0.0.4 lib/neoon/node.rb