Permalink
Browse files

Adding areas to the MLS gem.

  • Loading branch information...
1 parent 73e3c04 commit ef02c6ff20f1508733ef877074aa657e8aea7237 @waratuman waratuman committed Oct 2, 2012
Showing with 36 additions and 0 deletions.
  1. +2 −0 lib/mls.rb
  2. +27 −0 lib/mls/models/area.rb
  3. +7 −0 lib/mls/properties/hash.rb
View
2 lib/mls.rb
@@ -401,6 +401,7 @@ def self.parse(json) # TODO: testme
require 'mls/properties/decimal'
require 'mls/properties/datetime'
require 'mls/properties/string'
+require 'mls/properties/hash'
# Models
require 'mls/model'
@@ -410,3 +411,4 @@ def self.parse(json) # TODO: testme
require 'mls/models/photo'
require 'mls/models/tour_request'
require 'mls/models/flyer'
+require 'mls/models/area'
View
27 lib/mls/models/area.rb
@@ -0,0 +1,27 @@
+class MLS::Area < MLS::Resource
+
+ property :id, Fixnum, :serialize => :if_present
+ property :name, String, :serialize => :if_present
+ property :level, Fixnum, :serialize => :if_present
+ property :type, String, :serialize => :if_present
+ property :source, String, :serialize => :if_present
+ property :geometry, Hash, :serialize => false
+
+ # Counter caches
+ property :listings_count, Fixnum, :serialize => :false
+
+ class << self
+
+ def find(id)
+ response = MLS.get("/areas/#{id}")
+ MLS::Area::Parser.parse(response.body)
+ end
+
+ end
+
+end
+
+
+class MLS::Area::Parser < MLS::Parser
+
+end
View
7 lib/mls/properties/hash.rb
@@ -0,0 +1,7 @@
+class MLS::Property::Hash < MLS::Property
+
+ def load(value) # from_json
+ value
+ end
+
+end

0 comments on commit ef02c6f

Please sign in to comment.