lib/lean-attributes/attributes/type_coercion_method.rb
# Uses a default method body to do basic coercion for a handful of known
# types, or generates a generic `<AttributeClass>.new` conditional for
# other types
#
# @return [String] the coercion method's inner body
#
# @see METHOD_BODIES
Uses a default method body to do basic coercion for a handful of known
types, or generates a generic `.new` conditional for
other types
Uses a default method body to do basic coercion for a handful of known types or generates a generic ` . new ` conditional for other types
def body
        if (method_body = METHOD_BODIES[@type])
          return "#{method_body} unless value.nil?"
        end
        <<-RUBY.chomp
          return if value.nil?
          return #{@type}.new(value) if !value.is_a?(#{@type})
          value
        RUBY
      end
def body if ( method_body = METHOD_BODIES [ @type ] ) return "#{method_body} unless value.nil?" end <<-RUBY . chomp 
          return if value.nil?
          return  #{ @type } .new(value) if !value.is_a?( #{ @type } )
          value
         RUBY end
Uses a default method body to do basic coercion for a handful of known
types, or generates a generic `<AttributeClass>.new` conditional for
other types
Uses a default method body to do basic coercion for a handful of known types or generates a generic ` <AttributeClass > . new ` conditional for other types
the coercion method's inner body
the coercion method ' s inner body
String
see
None