Module: ActiveFedora::AttachedFiles::ClassMethods

Defined in:
lib/active_fedora/attached_files.rb

Instance Method Summary collapse

Instance Method Details

#ds_specsObject



159
160
161
162
# File 'lib/active_fedora/attached_files.rb', line 159

def ds_specs
  Deprecation.warn(self, "ds_specs is deprecated and will be removed in ActiveFedora 10.0")
  child_resource_reflections
end

#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::File) The class the datastream should have @option args [Boolean] :autocreate Always create this datastream on new objects

  • #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::File) The class the datastream should have @option args [Boolean] :autocreate Always create this datastream on new objects



203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/active_fedora/attached_files.rb', line 203

def has_file_datastream(*args)
  Deprecation.warn(self, "has_file_datastream is deprecated and will be removed in ActiveFedora 10.0. Use has_subresource instead.")
  if args.first.is_a? String
    name = args.first
    args = args[1] || {}
    args[:name] = name
  else
    args = args.first || {}
  end
  name = args.delete(:name)
  args[:class_name] = args.delete(:type).to_s
  has_subresource(name, args)
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 “ActiveFedora::File”

  • :name (String)

    the handle to refer to this datastream as

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

    Always create this datastream on new objects

Yields:

  • block executed by some kinds of datastreams

Raises:

  • (ArgumentError)


176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/active_fedora/attached_files.rb', line 176

def (*args, &block)
  Deprecation.warn(self, "has_metadata is deprecated and will be removed in ActiveFedora 10.0. Use has_subresource instead.")
  if args.first.is_a? String
    name = args.first
    args = args[1] || {}
    args[:name] = name
  else
    args = args.first || {}
  end
  name = args.delete(:name)
  raise ArgumentError, "You must provide a :type property for the datastream '#{name}'" unless args[:type]
  args[:class_name] = args.delete(:type).to_s
  has_subresource(name, args, &block)
end