Class: CloudSearch::Document
- Inherits:
-
Object
- Object
- CloudSearch::Document
- Defined in:
- lib/eden_cloud_search/document.rb
Constant Summary collapse
- MAX_VERSION =
4294967295
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#id ⇒ Object
Returns the value of attribute id.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#type ⇒ Object
Returns the value of attribute type.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(attributes = {}) ⇒ Document
constructor
A new instance of Document.
- #to_json ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Document
Returns a new instance of Document.
8 9 10 |
# File 'lib/eden_cloud_search/document.rb', line 8 def initialize(attributes = {}) attributes.each_pair { |key, value| self.__send__("#{key}=", value) } end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/eden_cloud_search/document.rb', line 6 def errors @errors end |
#fields ⇒ Object
Returns the value of attribute fields.
5 6 7 |
# File 'lib/eden_cloud_search/document.rb', line 5 def fields @fields end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/eden_cloud_search/document.rb', line 6 def id @id end |
#lang ⇒ Object
Returns the value of attribute lang.
5 6 7 |
# File 'lib/eden_cloud_search/document.rb', line 5 def lang @lang end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/eden_cloud_search/document.rb', line 5 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
6 7 8 |
# File 'lib/eden_cloud_search/document.rb', line 6 def version @version end |
Instance Method Details
#as_json ⇒ Object
36 37 38 39 40 |
# File 'lib/eden_cloud_search/document.rb', line 36 def as_json {:type => type, :id => id, :version => version}.tap do |hash| hash.merge!(:lang => lang, :fields => fields) if type == "add" end end |
#to_json ⇒ Object
42 43 44 |
# File 'lib/eden_cloud_search/document.rb', line 42 def to_json JSON.unparse as_json end |
#valid? ⇒ Boolean
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/eden_cloud_search/document.rb', line 24 def valid? @errors = {} run_id_validations run_version_validations run_type_validations if type == "add" run_lang_validations run_fields_validations end errors.empty? end |