Class: SiteRecord

Inherits:
MongoRecord show all
Extended by:
SiteModel
Defined in:
lib/yodel/models/core/record/site_record.rb

Direct Known Subclasses

LogEntry, Model, Record, Task, Trigger

Constant Summary

Constants inherited from AbstractRecord

AbstractRecord::CALLBACKS, AbstractRecord::FIELD_CALLBACKS, AbstractRecord::ORDERS

Instance Attribute Summary collapse

Attributes inherited from AbstractRecord

#changed, #errors, #stash, #typecast, #values

Instance Method Summary collapse

Methods included from SiteModel

load, scoped, scoped_for

Methods included from MongoModel

#collection, #load, #scoped

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

#siteObject (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_valuesObject



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_hashObject



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_paramsObject



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_idObject



13
# File 'lib/yodel/models/core/record/site_record.rb', line 13

def site_id;  @values['_site_id']; end