Module: Cistern::Singular
- Includes:
- Model
- Defined in:
- lib/cistern/singular.rb
Instance Attribute Summary
Attributes included from Model
#cistern
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Model
#==, #cistern_class, cistern_model, #hash, #initialize, #inspect, #save, #service, #service=, #service_class, #update, #wait_for, #wait_for!
#hash_except, #hash_except!, #hash_slice, #hash_stringify_keys
#attributes, #changed, #clone_attributes, #dirty?, #dirty_attributes, #dirty_request_attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #read_attribute, #request_attributes, #requires, #requires_one, #stage_attributes, #write_attribute
Class Method Details
.cistern_singular(cistern, klass, name) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/cistern/singular.rb', line 6
def self.cistern_singular(cistern, klass, name)
cistern.const_get(:Collections).module_eval " def \#{name}(attributes={})\n \#{klass.name}.new(attributes.merge(cistern: self))\n end\n EOS\nend\n", __FILE__, __LINE__
|
.included(klass) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/cistern/singular.rb', line 14
def self.included(klass)
super
klass.send(:extend, Cistern::Attributes::ClassMethods)
klass.send(:include, Cistern::Attributes::InstanceMethods)
klass.send(:extend, Cistern::Model::ClassMethods)
klass.send(:extend, Cistern::Associations)
end
|
Instance Method Details
#collection ⇒ Object
23
24
25
|
# File 'lib/cistern/singular.rb', line 23
def collection
self
end
|
#get ⇒ Object
27
28
29
|
# File 'lib/cistern/singular.rb', line 27
def get
raise NotImplementedError
end
|
#reload ⇒ Object
Also known as:
load
31
32
33
34
|
# File 'lib/cistern/singular.rb', line 31
def reload
get
self
end
|