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, #attributes=, #changed, #dirty?, #dirty_attributes, #dump, #dup, #identity, #identity=, #merge_attributes, #new_record?, #read_attribute, #requires, #requires_one, #stage_attributes, #write_attribute
Class Method Details
.cistern_singular(cistern, klass, name) ⇒ Object
4
5
6
7
8
9
10
|
# File 'lib/cistern/singular.rb', line 4
def self.cistern_singular(cistern, klass, name)
cistern.const_get(:Collections).module_eval "def \#{name}(attributes={})\n\#{klass.name}.new(attributes.merge(cistern: self))\nend\n", __FILE__, __LINE__
end
|
.included(klass) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/cistern/singular.rb', line 12
def self.included(klass)
super
klass.send(:extend, Cistern::Attributes::ClassMethods)
klass.send(:include, Cistern::Attributes::InstanceMethods)
klass.send(:extend, Cistern::Model::ClassMethods)
end
|
Instance Method Details
#collection ⇒ Object
20
21
22
|
# File 'lib/cistern/singular.rb', line 20
def collection
self
end
|
#get ⇒ Object
24
25
26
|
# File 'lib/cistern/singular.rb', line 24
def get
raise NotImplementedError
end
|
#reload ⇒ Object
Also known as:
load
28
29
30
31
|
# File 'lib/cistern/singular.rb', line 28
def reload
get
self
end
|