Skip to content

Commit

Permalink
load rich types from app/rich_types
Browse files Browse the repository at this point in the history
  • Loading branch information
al2o3cr committed Feb 10, 2010
1 parent e2fbec1 commit 4993f53
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/hobo_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ def enable
# Add the fields do declaration to ActiveRecord::Base
ActiveRecord::Base.send(:include, HoboFields::FieldsDeclaration)

# automatically load other rich types from app/rich_types/*.rb
# don't assume we're in a Rails app
if defined?(::Rails)
Dir[File.join(::Rails.root, 'app', 'rich_types', '*.rb')].each do |f|
# TODO: should we complain if field_types doesn't get a new value? Might be useful to warn people if they're missing a register_type
require f
end
end

# Monkey patch ActiveRecord so that the attribute read & write methods
# automatically wrap richly-typed fields.
ActiveRecord::AttributeMethods::ClassMethods.class_eval do
Expand Down

0 comments on commit 4993f53

Please sign in to comment.