Class: SiteRecord
- Inherits:
-
MongoRecord
- Object
- AbstractRecord
- MongoRecord
- SiteRecord
- Extended by:
- SiteModel
- Defined in:
- lib/yodel/models/core/record/site_record.rb
Constant Summary
Constants inherited from AbstractRecord
AbstractRecord::CALLBACKS, AbstractRecord::FIELD_CALLBACKS, AbstractRecord::ORDERS
Instance Attribute Summary collapse
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Attributes inherited from AbstractRecord
#changed, #errors, #stash, #typecast, #values
Instance Method Summary collapse
- #default_values ⇒ Object
-
#initialize(site, values = {}, new_record = true) ⇒ SiteRecord
constructor
A new instance of SiteRecord.
- #inspect_hash ⇒ Object
- #perform_reload(params) ⇒ Object
- #prepare_reload_params ⇒ Object
- #site_id ⇒ Object
Methods included from SiteModel
Methods included from MongoModel
Methods included from AbstractModel
#embed_many, #embed_one, #field, #fields, #many, #modify_field, #one, #remove_field
Methods inherited from MongoRecord
#collection, #fields, #id, #increment!, #load_from_mongo, #load_mongo_document, #perform_destroy, #perform_save, #set_id
Methods inherited from AbstractRecord
#changed!, #changed?, #clear_key, #destroy, #destroyed?, #eql?, #errors?, #field, #field?, #field_was, #fields, #from_json, #get, #get_meta, #get_raw, #hash, #id, #increment!, inherited, #inspect, #inspect_value, #method_missing, #new?, #present?, #reload, #save, #save_without_validation, #search_terms, #set, #set_meta, #set_raw, #to_json, #to_str, #trigger_field_callback, #update, #valid?
Constructor Details
#initialize(site, values = {}, new_record = true) ⇒ SiteRecord
Returns a new instance of SiteRecord.
8 9 10 11 |
# File 'lib/yodel/models/core/record/site_record.rb', line 8 def initialize(site, values={}, new_record=true) @site = site super(values, new_record) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AbstractRecord
Instance Attribute Details
#site ⇒ Object (readonly)
Returns the value of attribute site.
6 7 8 |
# File 'lib/yodel/models/core/record/site_record.rb', line 6 def site @site end |
Instance Method Details
#default_values ⇒ Object
15 16 17 |
# File 'lib/yodel/models/core/record/site_record.rb', line 15 def default_values super.merge({'_site_id' => site.id}) end |
#inspect_hash ⇒ Object
19 20 21 |
# File 'lib/yodel/models/core/record/site_record.rb', line 19 def inspect_hash {site_id: site_id}.merge(super) end |
#perform_reload(params) ⇒ Object
23 24 25 26 |
# File 'lib/yodel/models/core/record/site_record.rb', line 23 def perform_reload(params) document = load_mongo_document(_id: params[:id]) initialize(params[:site], document) end |
#prepare_reload_params ⇒ Object
28 29 30 |
# File 'lib/yodel/models/core/record/site_record.rb', line 28 def prepare_reload_params super.tap {|vals| vals[:site] = site} end |
#site_id ⇒ Object
13 |
# File 'lib/yodel/models/core/record/site_record.rb', line 13 def site_id; @values['_site_id']; end |