Sha256: d7cbe525c11aa3b626c502c6cc939e471d61ccebf10b01402955fd739595d2a7
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
class TokyoMetro::Factory::Convert::Common::Api::MetaClass::Converter::InfoForConversion def initialize( for_conversion , attr_of_info , method_for_deciding_default_value , arrow_blank: true ) @for_conversion = for_conversion @attr_of_info = attr_of_info @method_for_deciding_default_value = method_for_deciding_default_value @arrow_blank = arrow_blank end def match?( info ) valid_blank? or ( class_is_valid? and info.send( @attr_of_info ) == @for_conversion ) or ( hash_for_conversion_is_set? and info.send( @attr_of_info ) == convert_from and convert_from.send( @method_for_deciding_default_value ) ) end def process ::Proc.new { | info | if to_process?( info ) info.instance_variable_set( "@#{ @attr_of_info }" , convert_to ) end } end private def arrow_blank? @arrow_blank end def valid_blank? arrow_blank? and @for_conversion.blank? end def class_is_valid? @for_conversion.send( @method_for_deciding_default_value ) end def hash_for_conversion_is_set? @for_conversion.instance_of?( ::Hash ) end def to_process?( info ) hash_for_conversion_is_set? and convert_to.present? and convert_to.send( @method_for_deciding_default_value ) and info.send( @attr_of_info ) == convert_from end def convert_from @for_conversion[ :from ] end def convert_to @for_conversion[ :to ] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tokyo_metro-0.10.1 | lib/tokyo_metro/factory/convert/common/api/meta_class/converter/info_for_conversion.rb |