Sha256: 2a956d3c9dd7d9fcc9077fd0261ef147987a3e68b581efd2fb5b1ce83b2d363a
Contents?: true
Size: 813 Bytes
Versions: 10
Compression:
Stored size: 813 Bytes
Contents
require 'action_controller' module Betterdocs::Representer extend ActiveSupport::Concern def as_json(*) singleton_class.ancestors.find do |c| c != singleton_class && c < Betterdocs::Representer end.hashify(self) end def to_json(*a) JSON::generate(as_json, *a) end module ClassMethods def apply(object) object.extend self end def build_result_object {} end def hashify(object, &block) apply(object) result = build_result_object instance_exec(result, &block) result end def doc(type, name, **options, &block) docs.add_element(self, type, name, **options, &block) end def object_name(*) end def docs raise NotImplementedError, 'has to be implemented in including module' end end end
Version data entries
10 entries across 10 versions & 1 rubygems