Created
May 29, 2012 14:03
-
-
Save german/2828602 to your computer and use it in GitHub Desktop.
example of active_record methods introspection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading development environment (Rails 2.3.5) | |
>> module ActiveRecord | |
>> Base.singleton_methods.each do |m| | |
?> Base.class_eval <<-EOS | |
class << self | |
puts "redefining #{m}" | |
define_method "#{m}_with_introspection" do |*args| | |
puts "#{m}" | |
send(:"#{m}_without_introspection", *args) | |
end | |
alias_method :"#{m}_without_introspection", :"#{m}" | |
alias_method :"#{m}", :"#{m}_with_introspection" | |
end | |
EOS | |
>> end | |
>> end | |
redefining add_indexes | |
redefining spawn_reconnect | |
redefining inspect | |
redefining class_of_active_record_descendant | |
redefining delete_observer | |
redefining record_timestamps= | |
redefining scope | |
redefining reset_table_name | |
redefining default_scope | |
redefining schema_format | |
redefining qcol | |
redefining self_and_descendants_from_active_record | |
redefining after_validation | |
redefining table_exists? | |
redefining aggregate_mapping | |
redefining schema_format= | |
redefining preload_associations | |
redefining columns | |
redefining benchmark | |
redefining commit | |
redefining delete_all | |
redefining after_validation_on_create_callback_chain | |
redefining abstract_class | |
redefining delete_observers | |
redefining check_partition | |
redefining store_full_sti_class | |
redefining after_save_callback_chain | |
redefining create_temp_table | |
redefining human_attribute_name | |
redefining abstract_class= | |
redefining before_validation_on_create | |
redefining validate | |
redefining store_full_sti_class= | |
redefining cache_attribute? | |
redefining sum | |
redefining replace_named_bind_variables | |
redefining abstract_class? | |
redefining reload_table | |
redefining match_attribute_method? | |
redefining count_observers | |
redefining partition | |
redefining class_name_of_active_record_descendant | |
redefining default_scoping | |
redefining drop_temp_table | |
redefining validates_format_of | |
redefining after_validation_on_create | |
redefining default_scoping= | |
redefining backup_and_delete | |
redefining update_all | |
redefining before_validation_on_update_callback_chain | |
redefining nested_attributes_options | |
redefining sanitize_sql_array | |
redefining validate_find_options | |
redefining before_create_callback_chain | |
redefining reflect_on_association | |
redefining validates_inclusion_of | |
redefining before_validation_on_update | |
redefining quote_value | |
redefining nested_attributes_options= | |
redefining reflect_on_all_associations | |
redefining repartition | |
redefining quoted_locking_column | |
redefining primary_key_prefix_type | |
redefining current_user | |
redefining calculate | |
redefining store_full_sti_class? | |
redefining before_save | |
redefining reflect_on_all_aggregations | |
redefining raise_if_bind_arity_mismatch | |
redefining belongs_to | |
redefining uncached | |
redefining truncate_table | |
redefining generated_methods? | |
redefining sti_name | |
redefining observers | |
redefining is_external? | |
redefining primary_key_prefix_type= | |
redefining validate_callback_chain | |
redefining validates_each | |
redefining set_table_name | |
redefining accepts_nested_attributes_for | |
redefining sanitize_sql_hash_for_conditions | |
redefining truncate_partition | |
redefining first | |
redefining define_attribute_methods | |
redefining after_validation_on_update | |
redefining observers= | |
redefining has_delete? | |
redefining connection_handler | |
redefining construct_count_options_from_args | |
redefining validates_size_of | |
redefining columns_hash | |
redefining after_save | |
redefining composed_of | |
redefining class_name | |
redefining after_validation_on_update_callback_chain | |
redefining group_concat_sql | |
redefining sanitize_sql_for_assignment | |
redefining connection_handler= | |
redefining merge_conditions | |
redefining is_heap? | |
redefining set_readonly_option! | |
redefining reset_primary_key | |
redefining drop_partition | |
redefining after_create_callback_chain | |
redefining import_from_temp_table | |
redefining reflections | |
redefining validates_exclusion_of | |
redefining human_name | |
redefining increment_counter | |
redefining reset_locking_column | |
redefining average | |
redefining create_reflection | |
redefining table_name_prefix | |
redefining validates_uniqueness_of | |
redefining allow_concurrency | |
redefining table_name | |
redefining count_distinct | |
redefining instance_method_already_implemented? | |
redefining table_name_prefix= | |
redefining validate_on_create_callback_chain | |
redefining validates_confirmation_of | |
redefining sanitize_sql_hash_for_assignment | |
redefining drop_old_partitions | |
redefining allow_concurrency= | |
redefining get_primary_key | |
redefining delete | |
redefining table_name= | |
redefining clear_temp_table | |
redefining alias_attribute | |
redefining new_partition | |
redefining depending_on_previous_bucket? | |
redefining create | |
redefining subclasses | |
redefining decrement_counter | |
redefining update_counters_with_lock | |
redefining compute_type | |
redefining valid_keys_for_has_one_association | |
redefining classify_table | |
redefining clear_active_connections! | |
redefining column_names | |
redefining connection | |
redefining before_destroy_callback_chain | |
redefining concat_sql | |
redefining valid_keys_for_has_one_association= | |
redefining vacuum_tables | |
redefining before_update_callback_chain | |
redefining validates_associated | |
redefining === | |
redefining before_destroy | |
redefining partition_start | |
redefining count | |
redefining attr_protected | |
redefining table_name_suffix | |
redefining update_counters_without_lock | |
redefining current_user_proc | |
redefining verification_timeout | |
redefining after_find | |
redefining merge_hash_for_sync | |
redefining clear_all_connections! | |
redefining before_create | |
redefining scoped? | |
redefining timediff_sql | |
redefining table_name_suffix= | |
redefining validate_on_update_callback_chain | |
redefining current_user_proc= | |
redefining retrieve_connection | |
redefining verification_timeout= | |
redefining has_rows? | |
redefining has_many | |
redefining inheritance_column | |
redefining descends_from_active_record? | |
redefining find_by_sql | |
redefining start_transaction | |
redefining validates_numericality_of | |
redefining after_destroy | |
redefining find | |
redefining protected_attributes | |
redefining inheritance_column= | |
redefining partial_updates | |
redefining connection_pool | |
redefining content_columns | |
redefining after_create | |
redefining encode_quoted_value | |
redefining partial_updates= | |
redefining postgresql_connection | |
redefining after_destroy_callback_chain | |
redefining lock_optimistically | |
redefining validates_acceptance_of | |
redefining respond_to? | |
redefining finder_needs_type_condition? | |
redefining expand_hash_conditions_for_aggregates | |
redefining sanitize_sql_for_conditions | |
redefining after_update_callback_chain | |
redefining rollback | |
redefining lock_optimistically= | |
redefining silence | |
redefining attr_accessible | |
redefining with_scope | |
redefining valid_keys_for_belongs_to_association | |
redefining pluralize_table_names | |
redefining partitions | |
redefining locking_column | |
redefining valid_keys_for_belongs_to_association= | |
redefining pluralize_table_names= | |
redefining remove_connection | |
redefining configurations | |
redefining connected? | |
redefining sequence_name | |
redefining exists? | |
redefining sanitize_sql | |
redefining changed? | |
redefining gphost | |
redefining update | |
redefining locking_column= | |
redefining authorized_for? | |
redefining configurations= | |
redefining reflect_on_all_autosave_associations | |
redefining minimum | |
redefining accessible_attributes | |
redefining sequence_name= | |
redefining set_primary_key | |
redefining partition_end | |
redefining execute_grouped_calculation | |
redefining column_methods_hash | |
redefining transaction | |
redefining inherited | |
redefining has_and_belongs_to_many | |
redefining destroy_all | |
redefining base_class | |
redefining partition_names | |
redefining set_locking_column | |
redefining verify_active_connections! | |
redefining reset_sequence_name | |
redefining destroy | |
redefining before_validation_callback_chain | |
redefining attr_readonly | |
redefining changed | |
redefining maximum | |
redefining colorize_logging | |
redefining after_find_callback_chain | |
redefining execute_simple_calculation | |
redefining before_update | |
redefining count_by_sql | |
redefining all_partitions | |
redefining colorize_logging= | |
redefining establish_connection | |
redefining validates_presence_of | |
redefining get_all_tables | |
redefining reset_subclasses | |
redefining named_scope | |
redefining load_from_file | |
redefining notify_observers | |
redefining readonly_attributes | |
redefining current_scoped_methods | |
redefining attribute_method_suffix | |
redefining construct_calculation_sql | |
redefining valid_keys_for_has_and_belongs_to_many_association | |
redefining locking_enabled? | |
redefining reset_column_information | |
redefining after_update | |
redefining find_hidden_method | |
redefining partial_updates? | |
redefining add_columns | |
redefining sanitize_conditions | |
redefining valid_keys_for_has_many_association | |
redefining valid_keys_for_has_and_belongs_to_many_association= | |
redefining validates_length_of | |
redefining set_sequence_name | |
redefining after_initialize | |
redefining replace_bind_variables | |
redefining get_sync_list | |
redefining define_read_methods | |
redefining scoped | |
redefining after_validation_callback_chain | |
redefining partition_exists? | |
redefining quoted_table_name | |
redefining sanitize | |
redefining add_observer | |
redefining instantiate_observers | |
redefining valid_keys_for_has_many_association= | |
redefining scoped_methods | |
redefining check_partitions | |
redefining serialize | |
redefining after_initialize_callback_chain | |
redefining attribute_types_cached_by_default | |
redefining generated_methods | |
redefining clear_reloadable_connections! | |
redefining quote | |
redefining attribute_types_cached_by_default= | |
redefining create! | |
redefining expand_range_bind_variables | |
redefining has_one | |
redefining cache_attributes | |
redefining time_zone_aware_attributes | |
redefining scopes | |
redefining validate_on_create | |
redefining with_exclusive_scope | |
redefining last | |
redefining serialized_attributes | |
redefining all | |
redefining time_zone_aware_attributes= | |
redefining skip_time_zone_conversion_for_attributes | |
redefining method_added | |
redefining primary_key | |
redefining update_counters | |
redefining find_each | |
redefining skip_time_zone_conversion_for_attributes= | |
redefining define_callbacks | |
redefining sanitize_sql_hash | |
redefining set_inheritance_column | |
redefining alias_attribute_with_dirty | |
redefining before_validation_on_create_callback_chain | |
redefining default_timezone | |
redefining primary_key= | |
redefining cached_attributes | |
redefining logger | |
redefining use_temp_table? | |
redefining validate_on_update | |
redefining include_root_in_json | |
redefining before_save_callback_chain | |
redefining temp_table_name | |
redefining default_timezone= | |
redefining timestamped_migrations | |
redefining logger= | |
redefining cache | |
redefining reset_column_information_and_inheritable_attributes_for_all_subclasses | |
redefining before_validation | |
redefining include_root_in_json= | |
redefining reflect_on_aggregation | |
redefining timestamped_migrations= | |
redefining record_timestamps | |
redefining find_in_batches | |
redefining yaml_tag_subclasses? | |
redefining quote_bound_value | |
redefining alias_attribute_without_dirty | |
=> ["add_indexes", "spawn_reconnect", "inspect", "class_of_active_record_descendant", "delete_observer", "record_timestamps=", "scope", "reset_table_name", "default_scope", "schema_format", "qcol", "self_and_descendants_from_active_record", "after_validation", "table_exists?", "aggregate_mapping", "schema_format=", "preload_associations", "columns", "benchmark", "commit", "delete_all", "after_validation_on_create_callback_chain", "abstract_class", "delete_observers", "check_partition", "store_full_sti_class", "after_save_callback_chain", "create_temp_table", "human_attribute_name", "abstract_class=", "before_validation_on_create", "validate", "store_full_sti_class=", "cache_attribute?", "sum", "replace_named_bind_variables", "abstract_class?", "reload_table", "match_attribute_method?", "count_observers", "partition", "class_name_of_active_record_descendant", "default_scoping", "drop_temp_table", "validates_format_of", "after_validation_on_create", "default_scoping=", "backup_and_delete", "update_all", "before_validation_on_update_callback_chain", "nested_attributes_options", "sanitize_sql_array", "validate_find_options", "before_create_callback_chain", "reflect_on_association", "validates_inclusion_of", "before_validation_on_update", "quote_value", "nested_attributes_options=", "reflect_on_all_associations", "repartition", "quoted_locking_column", "primary_key_prefix_type", "current_user", "calculate", "store_full_sti_class?", "before_save", "reflect_on_all_aggregations", "raise_if_bind_arity_mismatch", "belongs_to", "uncached", "truncate_table", "generated_methods?", "sti_name", "observers", "is_external?", "primary_key_prefix_type=", "validate_callback_chain", "validates_each", "set_table_name", "accepts_nested_attributes_for", "sanitize_sql_hash_for_conditions", "truncate_partition", "first", "define_attribute_methods", "after_validation_on_update", "observers=", "has_delete?", "connection_handler", "construct_count_options_from_args", "validates_size_of", "columns_hash", "after_save", "composed_of", "class_name", "after_validation_on_update_callback_chain", "group_concat_sql", "sanitize_sql_for_assignment", "connection_handler=", "merge_conditions", "is_heap?", "set_readonly_option!", "reset_primary_key", "drop_partition", "after_create_callback_chain", "import_from_temp_table", "reflections", "validates_exclusion_of", "human_name", "increment_counter", "reset_locking_column", "average", "create_reflection", "table_name_prefix", "validates_uniqueness_of", "allow_concurrency", "table_name", "count_distinct", "instance_method_already_implemented?", "table_name_prefix=", "validate_on_create_callback_chain", "validates_confirmation_of", "sanitize_sql_hash_for_assignment", "drop_old_partitions", "allow_concurrency=", "get_primary_key", "delete", "table_name=", "clear_temp_table", "alias_attribute", "new_partition", "depending_on_previous_bucket?", "create", "subclasses", "decrement_counter", "update_counters_with_lock", "compute_type", "valid_keys_for_has_one_association", "classify_table", "clear_active_connections!", "column_names", "connection", "before_destroy_callback_chain", "concat_sql", "valid_keys_for_has_one_association=", "vacuum_tables", "before_update_callback_chain", "validates_associated", "===", "before_destroy", "partition_start", "count", "attr_protected", "table_name_suffix", "update_counters_without_lock", "current_user_proc", "verification_timeout", "after_find", "merge_hash_for_sync", "clear_all_connections!", "before_create", "scoped?", "timediff_sql", "table_name_suffix=", "validate_on_update_callback_chain", "current_user_proc=", "retrieve_connection", "verification_timeout=", "has_rows?", "has_many", "inheritance_column", "descends_from_active_record?", "find_by_sql", "start_transaction", "validates_numericality_of", "after_destroy", "find", "protected_attributes", "inheritance_column=", "partial_updates", "connection_pool", "content_columns", "after_create", "encode_quoted_value", "partial_updates=", "postgresql_connection", "after_destroy_callback_chain", "lock_optimistically", "validates_acceptance_of", "respond_to?", "finder_needs_type_condition?", "expand_hash_conditions_for_aggregates", "sanitize_sql_for_conditions", "after_update_callback_chain", "rollback", "lock_optimistically=", "silence", "attr_accessible", "with_scope", "valid_keys_for_belongs_to_association", "pluralize_table_names", "partitions", "locking_column", "valid_keys_for_belongs_to_association=", "pluralize_table_names=", "remove_connection", "configurations", "connected?", "sequence_name", "exists?", "sanitize_sql", "changed?", "gphost", "update", "locking_column=", "authorized_for?", "configurations=", "reflect_on_all_autosave_associations", "minimum", "accessible_attributes", "sequence_name=", "set_primary_key", "partition_end", "execute_grouped_calculation", "column_methods_hash", "transaction", "inherited", "has_and_belongs_to_many", "destroy_all", "base_class", "partition_names", "set_locking_column", "verify_active_connections!", "reset_sequence_name", "destroy", "before_validation_callback_chain", "attr_readonly", "changed", "maximum", "colorize_logging", "after_find_callback_chain", "execute_simple_calculation", "before_update", "count_by_sql", "all_partitions", "colorize_logging=", "establish_connection", "validates_presence_of", "get_all_tables", "reset_subclasses", "named_scope", "load_from_file", "notify_observers", "readonly_attributes", "current_scoped_methods", "attribute_method_suffix", "construct_calculation_sql", "valid_keys_for_has_and_belongs_to_many_association", "locking_enabled?", "reset_column_information", "after_update", "find_hidden_method", "partial_updates?", "add_columns", "sanitize_conditions", "valid_keys_for_has_many_association", "valid_keys_for_has_and_belongs_to_many_association=", "validates_length_of", "set_sequence_name", "after_initialize", "replace_bind_variables", "get_sync_list", "define_read_methods", "scoped", "after_validation_callback_chain", "partition_exists?", "quoted_table_name", "sanitize", "add_observer", "instantiate_observers", "valid_keys_for_has_many_association=", "scoped_methods", "check_partitions", "serialize", "after_initialize_callback_chain", "attribute_types_cached_by_default", "generated_methods", "clear_reloadable_connections!", "quote", "attribute_types_cached_by_default=", "create!", "expand_range_bind_variables", "has_one", "cache_attributes", "time_zone_aware_attributes", "scopes", "validate_on_create", "with_exclusive_scope", "last", "serialized_attributes", "all", "time_zone_aware_attributes=", "skip_time_zone_conversion_for_attributes", "method_added", "primary_key", "update_counters", "find_each", "skip_time_zone_conversion_for_attributes=", "define_callbacks", "sanitize_sql_hash", "set_inheritance_column", "alias_attribute_with_dirty", "before_validation_on_create_callback_chain", "default_timezone", "primary_key=", "cached_attributes", "logger", "use_temp_table?", "validate_on_update", "include_root_in_json", "before_save_callback_chain", "temp_table_name", "default_timezone=", "timestamped_migrations", "logger=", "cache", "reset_column_information_and_inheritable_attributes_for_all_subclasses", "before_validation", "include_root_in_json=", "reflect_on_aggregation", "timestamped_migrations=", "record_timestamps", "find_in_batches", "yaml_tag_subclasses?", "quote_bound_value", "alias_attribute_without_dirty"] | |
>> AggDemoDaily.first | |
inherited | |
respond_to? | |
changed | |
notify_observers | |
named_scope | |
scopes | |
first | |
find | |
validate_find_options | |
set_readonly_option! | |
scope | |
current_scoped_methods | |
scoped_methods | |
default_scoping | |
scope | |
current_scoped_methods | |
scoped_methods | |
scope | |
current_scoped_methods | |
scoped_methods | |
quoted_table_name | |
connection | |
retrieve_connection | |
connection_handler | |
table_name | |
reset_table_name | |
base_class | |
class_of_active_record_descendant | |
table_name_prefix | |
pluralize_table_names | |
table_name_suffix | |
set_table_name | |
finder_needs_type_condition? | |
descends_from_active_record? | |
abstract_class? | |
merge_conditions | |
connection | |
retrieve_connection | |
connection_handler | |
connection | |
retrieve_connection | |
connection_handler | |
find_by_sql | |
connection | |
retrieve_connection | |
connection_handler | |
sanitize_sql | |
quoted_table_name | |
connection | |
retrieve_connection | |
connection_handler | |
colorize_logging | |
inheritance_column | |
column_names | |
columns | |
connection | |
retrieve_connection | |
connection_handler | |
primary_key | |
reset_primary_key | |
base_class | |
class_of_active_record_descendant | |
get_primary_key | |
primary_key_prefix_type | |
set_primary_key | |
columns_hash | |
columns | |
default_timezone | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
serialized_attributes | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
columns_hash | |
=> #<AggDemoDaily bucket: "2011-08-01 00:00:00", text: "test"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment