Class: Behavior

Inherits:
Module show all
Defined in:
lib/more/facets/behavior.rb

Overview

Behavior

Constant Summary

Constants inherited from Module

Module::METHOD_TYPES

Constants included from Glue::Validation::ClassMethods

Glue::Validation::ClassMethods::LENGTHS

Instance Method Summary collapse

Methods inherited from Module

#*, #+, #-, #abstract, #alias_accessor!, #alias_reader!, #alias_setter, #alias_validator, #alias_writer!, #all_instance_methods, #ancestor?, #ann, #ann!, #annotations, #append_features, #append_features_without_class_extension, #append_features_without_classmethods, #attr, #attr_accessor!, #attr_reader!, #attr_setter, #attr_validator, #attr_writer!, #basename, #by_name, #class_def, #class_methods, #classified_attributes, #clone_removing, #clone_renaming, #clone_using, #conflict?, #define_dependency, #depend, #dependencies, #dirname, #equate_on, #extend, #extend_without_parameters, #heritage, #include, #include_as, #include_function_module, #include_without_parameters, #instance_interface, #instance_method!, #instance_method_defined?, #integrate, #is, #is?, #let, #memoize, #method_overloads, #method_space, #mixin_parameters, #modspace, #module_load, #module_method_defined?, #module_require, #nesting, #on_included, #overload, #prepend, #private_conflict?, #protected_conflict?, #public_conflict?, #revisal, #setting, #sort_on, #wrap_method

Methods included from Glue::Validation::ClassMethods

#validate_format, #validate_inclusion, #validate_length, #validate_numeric, #validate_value

Instance Method Details

#define(behavior, &body) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/more/facets/behavior.rb', line 37

def define(behavior, &body)
  if body
    define_method(behavior, &body)
  else
    behavior.each do |behavior, body|
      if body
        define_method(behavior, &body)
      elsif body.nil?
        remove_method(behavior)
      else
        undef_method(behavior)
      end
    end
  end
end