Module: Ork::Model::ClassMethods
- Defined in:
- lib/ork/model/class_methods.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #bucket ⇒ Object
-
#content_type(type = nil) ⇒ Object
When a value is given, sets the content_type of the object.
-
#create(atts = {}) ⇒ Object
Syntactic sugar for Model.new(atts).save.
- #defaults ⇒ Object
- #embedding ⇒ Object
- #indices ⇒ Object
- #uniques ⇒ Object
Instance Attribute Details
#bucket_name ⇒ Object
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
#attributes ⇒ Object
13 14 15 |
# File 'lib/ork/model/class_methods.rb', line 13 def attributes @attributes ||= [] end |
#bucket ⇒ Object
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 |
#defaults ⇒ Object
37 38 39 |
# File 'lib/ork/model/class_methods.rb', line 37 def defaults @defaults ||= {} end |
#embedding ⇒ Object
25 26 27 |
# File 'lib/ork/model/class_methods.rb', line 25 def @embedding ||= [] end |
#indices ⇒ Object
29 30 31 |
# File 'lib/ork/model/class_methods.rb', line 29 def indices @indices ||= {} end |
#uniques ⇒ Object
33 34 35 |
# File 'lib/ork/model/class_methods.rb', line 33 def uniques @uniques ||= [] end |