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
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 <<-EOS, __FILE__, __LINE__
def #{name}(attributes={})
#{klass.name}.new(attributes.merge(cistern: self))
end
EOS
end
|
.included(klass) ⇒ Object
Instance Method Details
#collection ⇒ Object
21
22
23
|
# File 'lib/cistern/singular.rb', line 21
def collection
self
end
|
#get ⇒ Object
25
26
27
|
# File 'lib/cistern/singular.rb', line 25
def get
raise NotImplementedError
end
|
#reload ⇒ Object
Also known as:
load
29
30
31
32
|
# File 'lib/cistern/singular.rb', line 29
def reload
get
self
end
|