Module: CouchbaseOrm::ActiveRecordCompat
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #_has_attribute?(attr_name) ⇒ Boolean
- #_write_attribute(attr_name, value) ⇒ Object
- #attribute_for_inspect(attr_name) ⇒ Object
- #attribute_names ⇒ Object
- #attribute_present?(attribute) ⇒ Boolean
- #format_for_inspect(value) ⇒ Object
- #has_attribute?(attr_name) ⇒ Boolean
- #read_attribute(attr_name, &block) ⇒ Object
Instance Method Details
#_has_attribute?(attr_name) ⇒ Boolean
90 91 92 |
# File 'lib/couchbase-orm/base.rb', line 90 def _has_attribute?(attr_name) attribute_names.include?(attr_name.to_s) end |
#_write_attribute(attr_name, value) ⇒ Object
123 124 125 126 |
# File 'lib/couchbase-orm/base.rb', line 123 def _write_attribute(attr_name, value) @attributes.write_from_user(attr_name.to_s, value) value end |
#attribute_for_inspect(attr_name) ⇒ Object
94 95 96 97 |
# File 'lib/couchbase-orm/base.rb', line 94 def attribute_for_inspect(attr_name) value = send(attr_name) value.inspect end |
#attribute_names ⇒ Object
110 111 112 |
# File 'lib/couchbase-orm/base.rb', line 110 def attribute_names self.class.attribute_names end |
#attribute_present?(attribute) ⇒ Boolean
118 119 120 121 |
# File 'lib/couchbase-orm/base.rb', line 118 def attribute_present?(attribute) value = send(attribute) !value.nil? && !(value.respond_to?(:empty?) && value.empty?) end |
#format_for_inspect(value) ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/couchbase-orm/base.rb', line 100 def format_for_inspect(value) if value.is_a?(String) && value.length > 50 "#{value[0, 50]}...".inspect elsif value.is_a?(Date) || value.is_a?(Time) %("#{value.to_s(:db)}") else value.inspect end end |
#has_attribute?(attr_name) ⇒ Boolean
114 115 116 |
# File 'lib/couchbase-orm/base.rb', line 114 def has_attribute?(attr_name) @attributes.key?(attr_name.to_s) end |
#read_attribute(attr_name, &block) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/couchbase-orm/base.rb', line 128 def read_attribute(attr_name, &block) name = attr_name.to_s name = self.class.attribute_aliases[name] || name name = @primary_key if name == 'id' && @primary_key @attributes.fetch_value(name, &block) end |