Module: Yapper::Document::Persistence::ClassMethods
- Defined in:
- lib/yapper/document/persistence.rb
Instance Method Summary collapse
- #create(*args) ⇒ Object
- #field(name, options = {}) ⇒ Object
- #index(*args) ⇒ Object
- #indexes ⇒ Object
- #search_index(*args) ⇒ Object
Instance Method Details
#create(*args) ⇒ Object
17 18 19 |
# File 'lib/yapper/document/persistence.rb', line 17 def create(*args) new(*args).tap { |doc| doc.save } end |
#field(name, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/yapper/document/persistence.rb', line 21 def field(name, ={}) name = name.to_sym self.fields[name] = define_method(name) do |*args, &block| self.attributes[name] end define_method("#{name}=".to_sym) do |*args, &block| self.set_attribute(name, args[0]) end end |
#index(*args) ⇒ Object
34 35 36 |
# File 'lib/yapper/document/persistence.rb', line 34 def index(*args) db.index(self, args) end |
#indexes ⇒ Object
42 43 44 |
# File 'lib/yapper/document/persistence.rb', line 42 def indexes db.indexes[self._type] end |
#search_index(*args) ⇒ Object
38 39 40 |
# File 'lib/yapper/document/persistence.rb', line 38 def search_index(*args) db.search_index(self, args) end |