lib/nrser/props/prop.rb
# Load a value for the prop from "data".
# 
# @param [*] data
# 
# @return [VALUE]
#   The prop value to use.
# 
Load a value for the prop from "data".
Load a value for the prop from " data " .
def value_from_data data
    value = case @from_data
    when nil
      if data.is_a?( String ) && type.has_from_s?
        type.from_s data
      elsif type.has_from_data?
        type.from_data data
      else
        data
      end
    when Symbol, String
      The custom `from_data` configuration specifies a string or symbol name,
      which we interpret as a class method on the defining class and call
      with the data to produce a value.
      @defined_in.send @from_data, data
    when Proc
      The custom `from_data` configuration provides a procedure, which we
      call with the data to produce the value.
      @from_data.call data
    else
      raise NRSER::TypeError.new \
        "Expected `@from_data` to be Symbol, String or Proc",
        "found", @from_data.class,
        :@from_data => @from_data,
        :@defined_in => @defined_in,
        details: <<~END        
          Acceptable types:
          -   Symbol or String
              -   Name of class method on the class this property is defined in
                  (`@defined_in`) to call with data to convert it to a
                  property value.
          -   Proc
              -   Procedure to call with data to convert it to a property value.
          END
    end
  end
def value_from_data data value = case @from_data when nil if data . is_a? ( String ) && type . has_from_s? type . from_s data elsif type . has_from_data? type . from_data data else data end when Symbol , String @defined_in . send @from_data , data when Proc @from_data . call data else raise NRSER :: TypeError . new "Expected `@from_data` to be Symbol, String or Proc" , "found" , @from_data . class , :@from_data => @from_data , :@defined_in => @defined_in , details : <<~END 
          Acceptable types:
          
          -   Symbol or String
              -   Name of class method on the class this property is defined in
                  (`@defined_in`) to call with data to convert it to a
                  property value.
                  
          -   Proc
              -   Procedure to call with data to convert it to a property value.
           END end end
Load a value for the prop from "data".
Load a value for the prop from " data " .
# This {Prop} does not have any custom `from_data` instructions, which # means we must rely on the {#type} to covert *data* to a *value*. #  # The custom `from_data` configuration specifies a string or symbol name, # which we interpret as a class method on the defining class and call # with the data to produce a value. # The custom `from_data` configuration provides a procedure, which we # call with the data to produce the value.
The prop value to use.
The prop value to use .
VALUE
data
<not_specific>
<not_specific>
None