Sha256: 97d9f9fb899618e55241bc13bbae2332332fe4ec92896bba0eb4969f6be4d02f

Contents?: true

Size: 968 Bytes

Versions: 1

Compression:

Stored size: 968 Bytes

Contents

module Neoid
  module ModelAdditions
    module ClassMethods
      def neoidable(options)
        @config = Neoid::ModelConfig.new
        yield(@config) if block_given?
        @neoidable_options = options
      end
    
      def neoidable_options
        @neoidable_options
      end
    
      def neo_index_name
        @index_name ||= "#{self.name.tableize}_index"
      end
    end
  
    module InstanceMethods
      def to_neo
        {}
      end

      protected
      def neo_properties_to_hash(*property_list)
        property_list.flatten.inject({}) { |all, property|
          all[property] = self.attributes[property]
          all
        }
      end

      private
      def _neo_representation
        @_neo_representation ||= begin
          results = neo_find_by_id
          if results
            neo_load(results.first['self'])
          else
            node = neo_create
            node
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neoid-0.0.2 lib/neoid/model_additions.rb