lib/lean-attributes/attributes/attribute.rb
def coercion_method
        <<-RUBY
          def #{coercion_method_name}(value)
            #{TypeCoercionMethod.method_name(@type)}(value)
          end
        RUBY
      end
# Generates a method definition as a String with the name
# `coerce_<attribute>`.
#
# @example
#   class Post
#     include Lean::Attributes
#
#     attribute :author, String
#     attribute :parent, Post
#
#     # generated_methods:
#     # def coerce_author(value)
#     #   coerce_string(value)
#     # end
#
#     # def coerce_parent(value)
#     #   coerce_post(value)
#     # end
#   end
#
# @return [String] method definition
#
# @see #coercion_method_name
# @see TypeCoercionMethod
Generates a method definition as a String with the name
`coerce_`.
Generates a method definition as a String with the name ` coerce_ ` .
def coercion_method
        <<-RUBY
          def #{coercion_method_name}(value)
            #{TypeCoercionMethod.method_name(@type)}(value)
          end
        RUBY
      end
def coercion_method <<-RUBY 
          def  #{ coercion_method_name } (value)
             #{ TypeCoercionMethod . method_name ( @type ) } (value)
          end
         RUBY end
Generates a method definition as a String with the name
`coerce_<attribute>`.
Generates a method definition as a String with the name ` coerce_<attribute > ` .
None
String
example
class Post include Lean::Attributes attribute :author, String attribute :parent, Post # generated_methods: # def coerce_author(value) # coerce_string(value) # end # def coerce_parent(value) # coerce_post(value) # end end
class Post include Lean :: Attributes attribute : author String attribute : parent Post # generated_methods : # def coerce_author ( value ) # coerce_string ( value ) # end # def coerce_parent ( value ) # coerce_post ( value ) # end end
see
None
see
None