Class: Spider::Model::ProxyModel

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

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_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, managed?, many, mapper, #mapper, #mapper=, mapper_include, mapper_include_for, #merge!, #merge_hash, #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

#method_missing(method, *arguments) ⇒ Object



31
32
33
# File 'lib/spiderfw/model/proxy_model.rb', line 31

def method_missing(method, *arguments)
    proxied.send("#{@prefix}#{method}", *arguments)
end

Class Method Details

.element(name, type, attributes = {}, &proc) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/spiderfw/model/proxy_model.rb', line 21

def self.element(name, type, attributes={}, &proc)
    super
    define_method(name) do
        @proxied.send(name)
    end
    define_method("#{name}=") do |val|
        @proxied.send("#{name}=", val)
    end
end

.prefixObject



13
14
15
# File 'lib/spiderfw/model/proxy_model.rb', line 13

def self.prefix
    @prefix
end

.proxiedObject



17
18
19
# File 'lib/spiderfw/model/proxy_model.rb', line 17

def self.proxied
    @proxied
end

.proxy(prefix, proxied) ⇒ Object



7
8
9
10
11
# File 'lib/spiderfw/model/proxy_model.rb', line 7

def self.proxy(prefix, proxied)
    @prefix = prefix
    @proxied = proxied
    return self
end