lib/jsonapionify/api/attribute.rb in jsonapionify-0.9.1 vs lib/jsonapionify/api/attribute.rb in jsonapionify-0.9.2

- old
+ new

@@ -1,9 +1,13 @@ require 'unstrict_proc' module JSONAPIonify::Api class Attribute + extend JSONAPIonify::Autoload + autoload_all + + include Documentation using UnstrictProc attr_reader :name, :type, :description, :read, :write, :required, :block def initialize( name, @@ -102,22 +106,10 @@ def required_for_action?(action_name, context) supports_write_for_action?(action_name, context) && (required === true || Array.wrap(required).include?(action_name)) end - def options_json_for_action(action_name, context) - { - name: @name, - type: @type.to_s, - description: JSONAPIonify::Documentation.onelinify_markdown(description), - example: example(context.resource.class.generate_id) - }.tap do |opts| - opts[:not_null] = true if @type.not_null? - opts[:required] = true if required_for_action?(action_name, context) - end - end - def read? !!@read end def write? @@ -131,19 +123,9 @@ when nil type.dump type.sample(name) else type.dump @example end - end - - def documentation_object - OpenStruct.new( - name: name, - type: type.name, - required: Array.wrap(required).join(', '), - description: JSONAPIonify::Documentation.render_markdown(description), - allow: allow - ) end def allow Array.new.tap do |ary| ary << 'read' if read?