module DbdOnto
  class Provenance < Base

    def initialize
      super
      self << provenance
      self << resource
    end

  private

    def provenance
      return @provenance if @provenance
      @provenance = Dbd::ProvenanceResource.new
      context_public = Dbd::ProvenanceFact.new(
        predicate: 'prov:context',
        object: 'public')
      @provenance << context_public
    end

    def resource
      return @resource if @resource
      @resource = Dbd::Resource.new(provenance_subject: provenance.subject)
      predicate_context = Dbd::Fact.new(
        predicate: 'meta:defines_predicate',
        object: 'prov:context')
      label_context = Dbd::Fact.new(
        predicate: RDF::RDFS.label.qname.join(':'),
        object: 'Context')
      @resource << predicate_context
      @resource << label_context
    end

  end
end

module DbdOnto
  class Provenance < Base

    def initialize
      super
      self << provenance
      self << resource
    end

  private

    def provenance
      return @provenance if @provenance
      @provenance = Dbd::ProvenanceResource.new
      @provenance << provenance_fact_context_public
    end

    def resource
      return @resource if @resource
      @resource = Dbd::Resource.new(provenance_subject: provenance.subject)
      @resource << fact_defines_predicate_prov_context
      @resource << fact_label_context
    end

    def provenance_fact_context_public
      Dbd::ProvenanceFact.new(predicate: 'prov:context', object: 'public')
    end

    def fact_defines_predicate_prov_context
      Dbd::Fact.new(predicate: 'meta:defines_predicate', object: 'prov:context')
    end

    def fact_label_context
      # TODO in Dbd : turn predicate into a proper Predicate class
      Dbd::Fact.new(predicate: RDF::RDFS.label.qname.join(':'), object: 'Context')
    end

  end
end

Apply some Sandi Metz rules for refactoring
Apply some Sandi Metz rules for refactoring

* a lot more readable now :-)
* spefically the paragraph below from
    http://robots.thoughtbot.com/post/50655960596/sandi-metz-rules-for-developers
  is relevant:

  "Having only one line per branch urged us to use well-named private methods
  to get work done. Private methods are great documentation. They need very
  clear names, which forced us to think about the content of the code we
  were extracting."
