No commit activity in last 3 years
No release in over 3 years
An ActiveFedora extension for registring attributes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0

Runtime

~> 0.8.2
 Project Readme

ActiveFedora::RegisteredAttributes

Gem Version Build Status

An ActiveFedora extension for consolidating the attribute definitions for an object.

By registering an attribute, we can introspect on the model for:

  • generating forms
  • generating default views
  • generating reasonably helpful API documentation/explanation
  • helping developers readily see what the data attributes are

Installation

Add this line to your application's Gemfile:

gem 'active_fedora-registered_attributes'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_fedora-registered_attributes

Usage

class Foo < ActiveFedora::Base
  include ActiveFedora::RegisteredAttributes

  has_metadata name: "descMetadata", type: FooMetadataDatastream

  attribute :title,
    datastream: :descMetadata, multiple: false,
    label: "Title of your Senior Thesis",
    validates: { presence: { message: 'Your must have a title.' } }

  attribute :creator,
    datastream: :descMetadata, multiple: true,
    label: "Author",
    hint: "Enter your preferred name",
    writer: :parse_person_names,
    reader: :parse_person_names,
    validates: { presence: { message: "You must have an author."} }
end

See ActiveFedora::RegisteredAttributes::Attribute

Internationalization

If you utilize internationalization, such as below, then regardless of what your model indicates as the label, it will use the internationalization.

en:
  activemodel:
    attributes:
      foo:
        internationalized_field: Welcome

TODO

  • Add internationalization support for hints and validation messages.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request