Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

here's an (out of date) readme + the license

  • Loading branch information...
commit e378d424d027cdee49c810388943c5f2d74053e2 1 parent 1aa4610
@ryan-allen ryan-allen authored
Showing with 71 additions and 0 deletions.
  1. +19 −0 MIT-LICENSE
  2. +52 −0 README
View
19 MIT-LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2007-2008 Ryan Allen, FlashDen Pty Ltd
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
52 README
@@ -0,0 +1,52 @@
+This module, when included, enforces the typical instantiation pattern
+that accepts a hash of attributes, like so:
+
+ class Car
+ include Modelling
+ attr_accessor :make
+ attr_accessor :model
+ end
+
+ car = Car.new(:make => 'Lotus', :model => 'Elise')
+ car.make # => 'Lotus'
+ car.model # => 'Elise'
+
+Additionally you get three meta methods for making your so called domain
+modelling a little more concise, these three methods are:
+
+ * attributes
+ * collections
+ * maps
+
+Attributes simply is an alias for attr_accessor, collections defines accessors
+that are arrays, and maps defines hashes. The constructor ensures that each
+map and collection are initalized as [] and {} respectively by default:
+
+ class Car
+ include Modelling
+ attributes :make, :model
+ collections :tyres, :accessories
+ maps :dealer_locations, :telephone_services
+ end
+
+ car = Car.new
+ car.make # => nil
+ car.model # => nil
+ car.tyres # => []
+ car.accessories # => []
+ car.dealer_locations # => {}
+ car.telephone_services # => {}
+
+TODO: WRITE DOCS FOR NEW CUSTOM INITIALIZERS!!!1 (AND UPDATE DOCS ABOVE,
+ THEY ARE LIKE OUT OF DATE OR SOMETHING).
+ i.e. collections :categories => CategoryCollection
+ and
+ attributes :total => Proc.new { Money.new(0) }
+ and
+ maps :domain => CustomDNSWithHashLookupAwesome
+
+This makes modelling with PORO's [1] more eloquent, and stops us from
+having to write and re-write constructors that accept hashes, as
+is typically done.
+
+[1] http://en.wikipedia.org/wiki/POJO
Please sign in to comment.
Something went wrong with that request. Please try again.