Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed unnecessary check on property reader.

  • Loading branch information...
commit 162836c82031db3788491d9e24c0f921d4f96813 1 parent 72c97f3
@paulcarey authored
Showing with 11 additions and 15 deletions.
  1. +11 −15 lib/relaxdb/document.rb
View
26 lib/relaxdb/document.rb
@@ -2,8 +2,6 @@ module RelaxDB
class Document
- TIME_REGEXP = /_at$|_on$|_date$|_time$/
-
include RelaxDB::Validators
# Used to store validation messages
@@ -35,22 +33,20 @@ class Document
class_inheritable_accessor :references_rels, :reader => true
self.references_rels = {}
+ # TODO: consider freezing prop names - more upto json - nothing for me to do
def self.property(prop, opts={})
properties << prop
-
- define_method(prop) do
- val = @data[prop.to_s]
-
- # Consider calling out to a method here - might be faster
- # than having it in each define_method - in fact, probably is
-
- # TODO: consider freezing prop names - more upto json - nothing for me to do
- if TIME_REGEXP =~ prop.to_s
- val = Time.parse(val).utc rescue val
+
+ if prop.to_s =~ /_at$|_on$|_date$|_time$/
+ define_method(prop) do
+ val = @data[prop.to_s]
+ Time.parse(val).utc rescue val
end
-
- val
- end
+ else
+ define_method(prop) do
+ @data[prop.to_s]
+ end
+ end
define_method("#{prop}=") do |val|
@data[prop.to_s] = val
Please sign in to comment.
Something went wrong with that request. Please try again.