Skip to content

Instantly share code, notes, and snippets.

View afred's full-sized avatar

Andrew Myers afred

  • WGBH Educational Foundation
  • Boston, MA
View GitHub Profile
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Created April 24, 2015 18:54
Are class types enforced on ActiveTriples properties?
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Created April 24, 2015 18:54
Are class types enforced on ActiveTriples properties?
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Created April 24, 2015 18:54
Are class types enforced on ActiveTriples properties?
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Last active August 29, 2015 14:19
Are class types enforced on ActiveTriples properties?
class MyDatastream < ActiveFedora::RDFDatastream
property :foo, predicate: ActiveTriples::Resource.new('http://example.com#foo'), class_name: 'Foo'
end
my_ds = MyDatastream.new
# I would expect this to whine.. but it doesn.
my_ds.foo = "this is definitely not a Foo"
class MyModel < ActiveFedora::Base
end

class MyDatastream < ActiveFedora::RDFDatastream
  property :foo, predicate: ActiveTriples:Resource.new('http://example.com#foo'), 
end
@afred
afred / sample.md
Last active August 29, 2015 14:22

app/models/generic_file.rb

class GenericFile < ActiveFedora::Base
  has_metadata 'descMetadata', type: MediaAnnotationDatastream
  has_attributes :title_attributes, datastream: 'descMetadata', multiple: true
  attr_accessible   :title_attributes     # <== needs to be changed to use strong params, yes?
end

app/models/datastream/media_annotation_datastream.rb

Handling pbcoreContributor, contributor, and contributorRole

Example: Contributor name as a literal.

NOTE: All PBCore input is using PBCore 2.0 XML unless otherwise specified.
NOTE: All RDF output is in Turtle format unless otherwise specified.

PBCore input:

<pbcoreDescriptionDocument>

Handling pbcoreCreator, creator, and creatorRole

Example: creator name is a literal.

NOTE: All PBCore input is using PBCore 2.0 XML unless otherwise specified.
NOTE: All RDF output is in Turtle format unless otherwise specified.

PBCore input:

<pbcoreDescriptionDocument>
@afred
afred / making_better_use_of_code_generators_in_hydra_gems.md
Created October 2, 2015 19:55
Making better use of code generators in Hydra gems.

Making better use of code generators in Hydra gems.

The problem:

  • Code that is generated by a gem (configuration, templates, etc) is only guaranteed to work with the version of the gem that generated it.

  • Upgrading the gem may cause the previously generated code to become obsolete.

@afred
afred / unobtrusive_monkey_patch_example.rb
Created November 6, 2015 20:31
A more passive way to monkey patch in ruby
# Suppose DogBehavior and Dog are defined in a gem.
module DogBehavior
def go_pee
puts "i am now peeing"
end
end
class Dog
include DogBehavior
end