Module: DataMapper::Is::Schemaless
- Included in:
- Model
- Defined in:
- lib/dm-is-schemaless/is/index.rb,
lib/dm-is-schemaless/is/version.rb,
lib/dm-is-schemaless/is/schemaless.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods Classes: Index
Constant Summary collapse
- VERSION =
'0.10.2'.freeze
Class Method Summary collapse
-
.included(base) ⇒ Object
fired when your plugin gets included into Resource.
Instance Method Summary collapse
-
#is_schemaless(options = {}) ⇒ Object
Methods that should be included in DataMapper::Model.
Class Method Details
.included(base) ⇒ Object
fired when your plugin gets included into Resource
7 8 |
# File 'lib/dm-is-schemaless/is/schemaless.rb', line 7 def self.included(base) end |
Instance Method Details
#is_schemaless(options = {}) ⇒ Object
Methods that should be included in DataMapper::Model. Normally this should just be your generator, so that the namespace does not get cluttered. ClassMethods and InstanceMethods gets added in the specific resources when you fire is :example
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dm-is-schemaless/is/schemaless.rb', line 16 def is_schemaless( = {}) # Add class-methods extend DataMapper::Is::Schemaless::ClassMethods # Add instance-methods include DataMapper::Is::Schemaless::InstanceMethods class_inheritable_accessor(:indexes) self.indexes ||= {} property :added_id, DataMapper::Types::Serial, :key => false property :type, DataMapper::Types::Discriminator property :id, DataMapper::Types::UUID, :unique => true, :required => true, :index => true, :default => Proc.new{ Guid.new.to_s } property :updated, DataMapper::Types::EpochTime, :key => true, :index => true, :default => Proc.new{ Time.now } property :body, DataMapper::Types::Json, :default => {} # before :save, :update_indexes end |