module Cistern::Singular

Public Class Methods

cistern_singular(cistern, klass, name) click to toggle source
# File lib/cistern/singular.rb, line 6
  def self.cistern_singular(cistern, klass, name)
    cistern.const_get(:Collections).module_eval <<-EOS, __FILE__, __LINE__
      def #{name}(attributes={})
        #{klass.name}.new(attributes.merge(cistern: self))
      end
    EOS
  end
included(klass) click to toggle source
Calls superclass method Cistern::Model::included
# File lib/cistern/singular.rb, line 14
def self.included(klass)
  super

  klass.send(:extend, Cistern::Attributes::ClassMethods)
  klass.send(:include, Cistern::Attributes::InstanceMethods)
  klass.send(:extend, Cistern::Model::ClassMethods)
  klass.send(:extend, Cistern::Associations)
end

Public Instance Methods

collection() click to toggle source
# File lib/cistern/singular.rb, line 23
def collection
  self
end
get() click to toggle source
# File lib/cistern/singular.rb, line 27
def get
  raise NotImplementedError
end
load()
Alias for: reload
reload() click to toggle source
# File lib/cistern/singular.rb, line 31
def reload
  get
  self
end
Also aliased as: load