annotation CrSerializer::Annotations::Accessor

Overview

Defines the method to use to get/set the property's value.

TODO Implement setter.

class Example
  include CrSerializer

  def initialize; end

  @[CRS::Accessor(getter: get_foo)]
  property foo : String = "foo"

  private def get_foo : String
    @foo.upcase
  end
end

Example.new.serialize JSON # => {"foo":"FOO"}

Defined in:

annotations.cr