79574353

Date: 2025-04-15 04:09:11
Score: 0.5
Natty:
Report link

Ah. It's pretty easy to access the attribute's custom option.

If the type is declared like this:

class QueryParamType < ActiveModel::Type::Value
  def type = :query_param

  def initialize(**args)
    @accepts = args[:accepts]
  end
end

then a caller can access the attribute's option value (for the Comment class above) like this:

Query::Comments.attribute_types["created_at"].accepts

Note that the hash keys of attribute_types are strings, not symbols.

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: nimmolo