Module: Ork::Model::ClassMethods

Defined in:
lib/ork/model/class_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bucket_nameObject



21
22
23
# File 'lib/ork/model/class_methods.rb', line 21

def bucket_name
  @bucket_name ||= self.to_s.downcase
end

Instance Method Details

#attributesObject



13
14
15
# File 'lib/ork/model/class_methods.rb', line 13

def attributes
  @attributes ||= []
end

#bucketObject



17
18
19
# File 'lib/ork/model/class_methods.rb', line 17

def bucket
  Ork.riak.bucket(bucket_name)
end

#content_type(type = nil) ⇒ Object

When a value is given, sets the content_type of the object. When the parameter is nil, it will return the content_type. It also sets as default the standard content_type.

Example:

class User
  include Ork:Document

  content_type 'text/plain'
end


52
53
54
55
# File 'lib/ork/model/class_methods.rb', line 52

def content_type(type = nil)
  @content_type = type unless type.nil?
  @content_type ||= 'application/json'
end

#create(atts = {}) ⇒ Object

Syntactic sugar for Model.new(atts).save



9
10
11
# File 'lib/ork/model/class_methods.rb', line 9

def create(atts = {})
  new(atts).save
end

#defaultsObject



37
38
39
# File 'lib/ork/model/class_methods.rb', line 37

def defaults
  @defaults ||= {}
end

#embeddingObject



25
26
27
# File 'lib/ork/model/class_methods.rb', line 25

def embedding
  @embedding ||= []
end

#indicesObject



29
30
31
# File 'lib/ork/model/class_methods.rb', line 29

def indices
  @indices ||= {}
end

#uniquesObject



33
34
35
# File 'lib/ork/model/class_methods.rb', line 33

def uniques
  @uniques ||= []
end