Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating "active_fedora:model" rails generator #116

Merged
merged 1 commit into from
Jun 21, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/generators/active_fedora/model/model_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class ModelGenerator < Rails::Generators::NamedBase
check_class_collision

class_option :directory, :type => :string, :default => 'models', :desc => "Which directory to generate? (i.e. app/DIRECTORY)"
class_option :has_file_datastream, :type => :string, :default => nil, :desc => "Name a file datastream to create"
class_option :descMetadata, :type => :string, :default => nil, :desc => "Add a descMetadata metadata datastream"

def install
template('model.rb.erb',File.join('app', directory, "#{file_name}.rb"))
Expand Down
25 changes: 25 additions & 0 deletions lib/generators/active_fedora/model/templates/model.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,30 @@
# `rails generate active_fedora::model <%= class_name %>`
require 'active_fedora/base'
class <%= class_name %> < ActiveFedora::Base
<% if options['descMetadata'] %>
has_metadata name: "descMetadata", type: <% options['descMetadata'] %>
<% else %>
# Uncomment the following lines to add a #descMetadata method that is a
# datastream. You will need to specify the :type:, which may involve
# creating a new Datastream object.
#
# has_metadata name: "descMetadata", type: <%= class_name %>MetadataDatastream
<%- end -%>
<% if options['has_file_datastream'] %>
has_file_datastream "<%= options['has_file_datastream'] %>"
<% else %>
# Uncomment the following lines to add an #attachment method that is a
# file_datastream:
#
# has_file_datastream "attachment"
<% end %>
# "If you need to add additional attributes to the SOLR document, define the
# #to_solr method and make sure to use super"
#
# def to_solr(solr_document={}, options={})
# super(solr_document, options)
# solr_document["my_attribute_s"] = my_attribute
# return solr_document
# end

end
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ describe <%= class_name %> do
subject.reload
}.to_not raise_error(ActiveFedora::ObjectNotFoundError)

assert_rels_ext_has_model(subject, JournalEntry)

subject.destroy
end

Expand Down