File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 1
1
require "my_mongoid/version"
2
+ require 'active_support/concern'
2
3
3
4
module MyMongoid
4
- # Your code goes here...
5
+
6
+ module Document
7
+ extend ActiveSupport ::Concern
8
+
9
+ @@models = [ ]
10
+
11
+ included do
12
+ extend ClassMethods
13
+
14
+ @@models << self
15
+
16
+ self . class_eval do
17
+ attr_accessor :attributes
18
+
19
+ def read_attribute ( key )
20
+ @attributes [ key ]
21
+ end
22
+
23
+ def write_attribute ( key , value )
24
+ @attributes [ key ] = value
25
+ end
26
+ end
27
+ end
28
+
29
+ def initialize ( attributes )
30
+ raise ArgumentError , 'It is not a hash' unless attributes . is_a? ( Hash )
31
+ @attributes = attributes
32
+
33
+ MyMongoid . models ||= [ ]
34
+
35
+ end
36
+
37
+ def MyMongoid . models
38
+ @@models
39
+ end
40
+
41
+ module ClassMethods
42
+ def is_mongoid_model?
43
+ true
44
+ end
45
+
46
+ def field
47
+
48
+ end
49
+ end
50
+ end
51
+
5
52
end
Original file line number Diff line number Diff line change
1
+ Subproject commit 2b9ec2cd424be18fd9b63a01ab77b9a49076796c
You can’t perform that action at this time.
0 commit comments