Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

[PERSISTANCE] fixed getter methods for underscore-options of unsaved rec... #932

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ examples/*.html
*.log
.rvmrc
.rbenv-version
.idea/
tmp/
2 changes: 1 addition & 1 deletion lib/tire/model/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def self.included(base)

['_score', '_type', '_index', '_version', 'sort', 'highlight', '_explanation'].each do |attr|
define_method("#{attr}=") { |value| @attributes ||= {}; @attributes[attr] = value }
define_method("#{attr}") { @attributes[attr] }
define_method("#{attr}") { @attributes.try(:[], attr) }
end

def self.search(*args, &block)
Expand Down
2 changes: 1 addition & 1 deletion lib/tire/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Tire
VERSION = "0.6.2"
VERSION = "0.6.2.1"

CHANGELOG =<<-END
IMPORTANT CHANGES LATELY:
Expand Down
4 changes: 4 additions & 0 deletions test/unit/model_persistence_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ class << a
assert_nothing_raised { PersistentArticle.new }
end

should "have getter methods for underscore-attributes of unsaved models" do
assert_nothing_raised { PersistentArticle.new._version }
end

should "have getter methods for attributes" do
assert_not_nil @article.title
assert_equal 'Test', @article.title
Expand Down