lib/brief/document/content_extractor.rb in brief-1.4.4 vs lib/brief/document/content_extractor.rb in brief-1.5.0

- old
+ new

@@ -9,19 +9,28 @@ def model_class Brief::Model.for_type(@model_type) end - def attribute_set + def content_schema_attributes model_class.definition.content_schema.attributes end + def extracted_content_data + me = self + content_schema_attributes.keys.reduce({}.to_mash) do |memo, attr| + val = me.send(attr) rescue nil + memo[attr] = val if val + memo + end + end + def respond_to?(meth) - attribute_set.key?(meth) || super + content_schema_attributes.key?(meth) || super end def method_missing(meth, *_args, &_block) - if settings = attribute_set.fetch(meth, nil) + if settings = content_schema_attributes.fetch(meth, nil) if settings.args.length == 1 && settings.args.first.is_a?(String) selector = settings.args.first matches = document.css(selector) if matches.length > 1