Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Myers afred

  • WGBH Educational Foundation
  • Boston, MA
View GitHub Profile
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Created Apr 24, 2015
Are class types enforced on ActiveTriples properties?
View class_type_enforcement_on_active_triples_properties.rb
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Created Apr 24, 2015
Are class types enforced on ActiveTriples properties?
View class_type_enforcement_on_active_triples_properties.rb
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Created Apr 24, 2015
Are class types enforced on ActiveTriples properties?
View class_type_enforcement_on_active_triples_properties.rb
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Last active Aug 29, 2015
Are class types enforced on ActiveTriples properties?
View class_type_enforcement_on_active_triples_properties.rb
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"
View datastream_vs_module.md
class MyModel < ActiveFedora::Base
end

class MyDatastream < ActiveFedora::RDFDatastream
  property :foo, predicate: ActiveTriples:Resource.new('http://example.com#foo'), 
end
View sample.md

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

View pbcoreContributor.md

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>
View pbcoreCreator.md

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 Oct 2, 2015
Making better use of code generators in Hydra gems.
View making_better_use_of_code_generators_in_hydra_gems.md

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 Nov 6, 2015
A more passive way to monkey patch in ruby
View unobtrusive_monkey_patch_example.rb
# 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