Rather than an acts_as_foo
syntax**, I'm toying with the idea of extending ActiveSensor::Base < ActiveRecord::Base
and then extending this base class with all the errors/validations/class methods/whizbangs.
Proposed: #active_sensor.rb gem
module ActiveSensor
include ActiveRecord
autoload :VERSION, 'active_sensor/version'
autoload :ActiveSensorError, 'active_sensor/base'
autoload :Base, 'active_sensor/base'
autoload :Validations, 'active_sensor/validations'
end
Pros:
I think it looks cleaner.
Architecture and class build-up emulates ActiveRecord
I have a lot of subclassing going on... want to check whether a component is hardware using :is_a?
method.
Cons: holding an extra inheritance class layer in memory... never used independently not very conventional (only seen 1 other rails plugin do this)
Any advice? Is creating a new ::Base class just dumb? If so, why?
** The acts_as_foo
pattern is common for Rails gems. This class method is added to every AR object, which loads and extends class and instance methods when loading the class.