Module: ActiveFedora::Datastreams::ClassMethods

Defined in:
lib/active_fedora/datastreams.rb

Instance Method Summary collapse

Instance Method Details

#has_file_datastream(name, args) ⇒ Object #has_file_datastream(args) ⇒ Object

Overloads:

  • #has_file_datastream(name, args) ⇒ Object

    Declares a file datastream exists for objects of this type

    Parameters:

    • name (String)
    • args (Hash)

      @option args :type (ActiveFedora::Datastream) The class the datastream should have @option args :label (“File Datastream”) The default value to put in the dsLabel field @option args :control_group (“M”) The type of controlGroup to store the datastream as. Defaults to M @option args [Boolean] :autocreate Always create this datastream on new objects @option args [Boolean] :versionable Should versioned datastreams be stored

  • #has_file_datastream(args) ⇒ Object

    Declares a file datastream exists for objects of this type

    Parameters:

    • args (Hash)

      @option args :name (“content”) The dsid of the datastream @option args :type (ActiveFedora::Datastream) The class the datastream should have @option args :label (“File Datastream”) The default value to put in the dsLabel field @option args :control_group (“M”) The type of controlGroup to store the datastream as. Defaults to M @option args [Boolean] :autocreate Always create this datastream on new objects @option args [Boolean] :versionable Should versioned datastreams be stored



243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/active_fedora/datastreams.rb', line 243

def has_file_datastream(*args)
  if args.first.is_a? String 
    name = args.first
    args = args[1] || {}
    args[:name] = name
  else
    args = args.first || {}
  end
  spec = {:autocreate => args.fetch(:autocreate, false), :type => args.fetch(:type,ActiveFedora::Datastream),
          :label =>  args.fetch(:label,"File Datastream"), :control_group => args.fetch(:control_group,"M")}
  spec[:versionable] = args[:versionable] if args.has_key? :versionable
  ds_specs[args.fetch(:name, "content")]= spec
end

#has_metadata(*args) { ... } ⇒ Object

This method is used to specify the details of a datastream. You can pass the name as the first argument and a hash of options as the second argument or you can pass the :name as a value in the args hash. Either way, name is required. Note that this method doesn’t actually execute the block, but stores it , to be executed by any the implementation of the datastream(specified as :type)

Parameters:

  • args (Hash)

Options Hash (*args):

  • :type (Class)

    The class that will represent this datastream, should extend “Datastream”

  • :name (String)

    the handle to refer to this datastream as

  • :label (String)

    sets the fedora label

  • :control_group (String)

    must be one of ‘E’, ‘X’, ‘M’, ‘R’

  • :disseminator (String)
  • :url (String)
  • :autocreate (Boolean)

    Always create this datastream on new objects

  • :versionable (Boolean)

    Should versioned datastreams be stored

Yields:

  • block executed by some kinds of datastreams



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/active_fedora/datastreams.rb', line 208

def (*args, &block)

  if args.first.is_a? String 
    name = args.first
    args = args[1] || {}
    args[:name] = name
  else
    args = args.first
  end
  
  
  spec = {:autocreate => args.fetch(:autocreate, false), :type => args[:type], :label =>  args.fetch(:label,""), :control_group => args[:control_group], :disseminator => args.fetch(:disseminator,""), :url => args.fetch(:url,""),:block => block}
  spec[:versionable] = args[:versionable] if args.has_key? :versionable
  ds_specs[args[:name]]= spec
end