Class: Spider::Model::Managed

Inherits:
BaseModel show all
Defined in:
lib/spiderfw/model/extended_models/managed.rb

Overview

The main superclass of non-legacy models. Extends the BaseModel providing an autoincrementing id and creation/modification timestamps. Defines the following elements:

element :id, Fixnum, :primary_key => true,:autoincrement => true, :read_only => true, :element_position => 0}
element :obj_created, DateTime, :hidden => true
element :obj_modified, DateTime, :hidden => true

Other modules may be mixed-in to add default functionality to managed models.

Instance Attribute Summary

Attributes inherited from BaseModel

#_check_if_saved, #_modified_elements, #_no_identity_mapper, #_parent, #_parent_element, #_subclass_object, #loaded_elements, #model

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#==, #[], #[]=, _added_elements, #_check, add_element, #after_delete, #after_save, all, #all_children, all_values_observers, app, attribute, auto_primary_keys?, #autoload, #autoload=, #autoload?, #become, #before_delete, #before_save, choice, class_table_inheritance, #clear_values, #clone, condition, containing_module, count, create, create_inline_model, #cut, define_element_methods, define_elements, #delete, #delete!, dump_element, #dump_to_all_data_hash, #dump_to_hash, #each, each_element, #each_val, element, element_association?, element_attributes, element_defined, #element_has_value?, #element_loaded, #element_loaded?, #element_modified?, element_query, elements, elements_array, #elements_modified?, embeddable?, #embedder, #empty?, #eql?, extend_model, extend_queryset, extended_models, find, first_definer, free_query_condition, from_hash_dump, from_yaml, #get, get, get_element, get_mapper, #get_new, #get_new_static, #get_no_load, get_storage, group, has_element?, #identity_mapper, #identity_mapper=, #in_storage?, in_transaction, inherit_storage, inherited, #initialize, #insert, #insert!, #inspect, #instantiate_element, integrate, integrate_element, junction?, #keys_string, keys_string, #keys_to_condition, label, label_plural, list, load, #load, load_or_create, many, mapper, #mapper, #mapper=, mapper_include, mapper_include_for, #merge!, #merge_hash, #method_missing, #modified?, multiple_choice, #no_autoload, not_embeddable, notify_observers, #notify_observers, #obj_pks, #observe_all_values, #observe_element, observe_element, observer_all_values, on_element_defined, only_embedded, only_embedded?, polymorphic, #polymorphic_become, #prepare_child, prepare_query, prepare_to_code, prepare_value, #prepare_value, #primary_keys, primary_keys, #primary_keys_hash, #primary_keys_set?, referenced_by_junctions, #remove_association, remove_element, remove_integrate, #reset_modified_elements, #respond_to?, #save, #save!, #save_all, #save_mode, #saving, sequence, #set, #set!, #set_hash, #set_loaded_value, #set_modified, #set_parent, #set_reverse, #set_values, short_name, split_keys_string, static, storage, #storage, #subclass, subclasses, submodels, sync_schema, to_code, #to_hash, #to_json, #to_s, to_s, #to_yaml, #to_yaml_h, #unit_of_work_available?, #update, #update!, use_storage, #use_storage, value_observers, where, with_mapper, with_mapper_for

Methods included from EventSource

included, #on, #trigger

Methods included from QueryFuncs

add_query_func, included

Methods included from Logger

add, close, close_all, datetime_format, datetime_format=, #debug, debug, debug?, #debug?, enquire_loggers, #error, error, #error?, error?, #fatal, fatal, #fatal?, fatal?, info, #info, info?, #info?, method_missing, open, reopen, send_to_loggers, unknown, #unknown, #warn, warn, warn?, #warn?

Constructor Details

This class inherits a constructor from Spider::Model::BaseModel

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Spider::Model::BaseModel

Class Method Details

.managed?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/spiderfw/model/extended_models/managed.rb', line 29

def self.managed?
    true
end

.no_set_datesObject



37
38
39
# File 'lib/spiderfw/model/extended_models/managed.rb', line 37

def self.no_set_dates
    @no_set_dates
end

.no_set_dates=(bool) ⇒ Object



33
34
35
# File 'lib/spiderfw/model/extended_models/managed.rb', line 33

def self.no_set_dates=(bool)
    @no_set_dates = bool
end

Instance Method Details

#_set_dates(bool = nil) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/spiderfw/model/extended_models/managed.rb', line 41

def _set_dates(bool=nil)
    return false if Spider::Model::Managed.no_set_dates
    @_set_dates = true if @_set_dates == nil
    @_set_dates = bool if bool != nil
    if self.class.extended_models
        self.class.extended_models.each do |mod, el|
            sup = self.get(el)
            sup._set_dates(bool) if sup
        end
    end
    @_set_dates
end

#assign_id(val) ⇒ Object

:nodoc:



25
26
27
# File 'lib/spiderfw/model/extended_models/managed.rb', line 25

def assign_id(val) #:nodoc:
    @id = val
end