lycra 0.0.7 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/awesome_print/ext/lycra_attribute.rb +25 -0
- data/lib/awesome_print/ext/lycra_attributes.rb +25 -0
- data/lib/awesome_print/formatters/lycra_attribute_formatter.rb +58 -0
- data/lib/awesome_print/formatters/lycra_attributes_formatter.rb +26 -0
- data/lib/elasticsearch/model/adapters/lycra.rb +2 -0
- data/lib/elasticsearch/model/adapters/lycra/document.rb +120 -0
- data/lib/elasticsearch/model/adapters/lycra/multiple.rb +70 -0
- data/lib/lycra.rb +20 -3
- data/lib/lycra/attributes.rb +146 -0
- data/lib/lycra/attributes/attribute.rb +143 -0
- data/lib/lycra/attributes/collection.rb +38 -0
- data/lib/lycra/awesome_print.rb +6 -0
- data/lib/lycra/decorator.rb +12 -0
- data/lib/lycra/decorator/model.rb +33 -0
- data/lib/lycra/document.rb +11 -0
- data/lib/lycra/document/model.rb +37 -0
- data/lib/lycra/document/proxy.rb +485 -0
- data/lib/lycra/document/registry.rb +38 -0
- data/lib/lycra/engine.rb +4 -1
- data/lib/lycra/errors.rb +18 -3
- data/lib/lycra/import.rb +116 -0
- data/lib/lycra/inheritance.rb +17 -0
- data/lib/lycra/monkeypatches.rb +7 -37
- data/lib/lycra/multidoc.rb +22 -0
- data/lib/lycra/search.rb +2 -2
- data/lib/lycra/serializer.rb +19 -0
- data/lib/lycra/serializer/model.rb +35 -0
- data/lib/lycra/types.rb +165 -0
- data/lib/lycra/version.rb +2 -2
- data/spec/spec_helper.rb +13 -8
- data/spec/support/foo.rb +120 -0
- metadata +53 -31
- data/app/documents/lycra/document.rb +0 -191
- data/lib/lycra/model.rb +0 -62
data/lib/lycra/model.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
module Lycra
|
2
|
-
module Model
|
3
|
-
def self.included(base)
|
4
|
-
base.send :extend, ClassMethods
|
5
|
-
base.send :include, Elasticsearch::Model
|
6
|
-
base.send :include, Elasticsearch::Model::Callbacks
|
7
|
-
|
8
|
-
base.send :lycra_document
|
9
|
-
|
10
|
-
base.send :delegate, :as_indexed_json, to: :lycra_document
|
11
|
-
end
|
12
|
-
|
13
|
-
def lycra_document
|
14
|
-
self.class.lycra_document.new(self)
|
15
|
-
end
|
16
|
-
|
17
|
-
module ClassMethods
|
18
|
-
def index_name(idx=nil)
|
19
|
-
lycra_document.index_name idx
|
20
|
-
end
|
21
|
-
|
22
|
-
def document_type(doctype=nil)
|
23
|
-
lycra_document.document_type doctype
|
24
|
-
end
|
25
|
-
|
26
|
-
def mapping(options={}, &block)
|
27
|
-
lycra_document.mapping options, &block
|
28
|
-
end
|
29
|
-
alias_method :mappings, :mapping
|
30
|
-
|
31
|
-
def lycra_document(klass=nil)
|
32
|
-
if klass.present?
|
33
|
-
if klass.respond_to?(:constantize)
|
34
|
-
@lycra_document = klass.constantize.new(self)
|
35
|
-
else
|
36
|
-
@lycra_document = klass.new(self)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
@lycra_document ||= lycra_document_klass.new(self)
|
41
|
-
end
|
42
|
-
|
43
|
-
def lycra_document_klass
|
44
|
-
begin
|
45
|
-
return "#{self.name}Document".constantize
|
46
|
-
rescue NameError => e
|
47
|
-
# noop, we just continue
|
48
|
-
end
|
49
|
-
|
50
|
-
if respond_to?(:base_class) && self.base_class.name != self.name
|
51
|
-
begin
|
52
|
-
return "#{self.base_class.name}Document".constantize
|
53
|
-
rescue NameError => e
|
54
|
-
# noop, we just continue
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
raise Lycra::DocumentNotFoundError.new(self)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|