lib/brief/model/definition.rb in brief-1.9.9 vs lib/brief/model/definition.rb in brief-1.9.11

- old
+ new

@@ -17,10 +17,12 @@ @type_alias = options.fetch(:type_alias) { name.downcase.parameterize.gsub(/-/, '_') } @metadata_schema = {}.to_mash @section_mappings = {}.to_mash @content_schema = { attributes: {} }.to_mash @model_class = options[:model_class] + + @doc_options = {}.to_mash end def valid? name.to_s.length > 0 && type_alias.to_s.length > 0 end @@ -57,9 +59,26 @@ @model_class || model_namespace.const_get(type_alias.camelize) rescue Brief.default_model_class end def model_namespace Brief.configuration.model_namespace || Brief::Model + end + + # TODO + # There is probably a way to inspect the filename of the code calling you + # which would be a better way of handling this that doesn't require + def defined_in(filename=nil) + if filename + filename = Pathname(filename) + @doc_options[:defined_in] = filename + end + + @doc_options[:defined_in] + end + + def documentation(options={}, &block) + @doc_options.merge!(options) if options + @doc_options end def meta(_options = {}, &block) @current = :meta instance_eval(&block)