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 <<-EOS, __FILE__, __LINE__
def #{name}(attributes={})
#{klass.name}.new(attributes.merge(cistern: self))
end
EOS
end
|
.included(klass) ⇒ Object
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
|