4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/enumerated_attribute/attribute/instance_methods.rb', line 4
def self.included(base)
method_missing_suffix = "enumerated_attribute_#{base.name.gsub(/.+::/,'')}_#{base.hash.abs}".to_sym
define_method("method_missing_with_#{method_missing_suffix}") do |methId, *args|
return self.__send__(methId) if define_enumerated_attribute_dynamic_method(methId)
self.__send__("method_missing_without_#{method_missing_suffix}", methId, *args)
end
respond_to_suffix = "enumerated_attribute_#{base.name.gsub(/.+::/,'')}_#{base.hash.abs}".to_sym
base.class_eval %{
def respond_to_with_#{respond_to_suffix}?(method, include_private=false)
self.respond_to_without_#{respond_to_suffix}?(method, include_private) ||
(!!parse_dynamic_method_parts!(method.to_s) rescue false)
end
}, __FILE__, __LINE__
base.safe_alias_method_chain :method_missing, method_missing_suffix
base.safe_alias_method_chain :respond_to?, respond_to_suffix
end
|