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 / jekyll_tutorials_for_samvera_connect_2018.md
Last active April 24, 2023 20:01
Jekyll Tutorials for Samvera Connect 2018
View jekyll_tutorials_for_samvera_connect_2018.md
@afred
afred / unobtrusive_monkey_patch_example.rb
Created November 6, 2015 20:31
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
@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.
View making_better_use_of_code_generators_in_hydra_gems.md
View pbcoreCreator.md
View pbcoreContributor.md
@afred
afred / sample.md
Last active August 29, 2015 14:22
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 datastream_vs_module.md
class MyModel < ActiveFedora::Base
end

class MyDatastream < ActiveFedora::RDFDatastream
  property :foo, predicate: ActiveTriples:Resource.new('http://example.com#foo'), 
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?
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"
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Created April 24, 2015 18:54
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 April 24, 2015 18:54
Are class types enforced on ActiveTriples properties?
View class_type_enforcement_on_active_triples_properties.rb
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end