Module: Parliament::Grom::Decorator

Defined in:
lib/parliament/grom/decorator.rb,
lib/parliament/grom/decorator/group.rb,
lib/parliament/grom/decorator/house.rb,
lib/parliament/grom/decorator/party.rb,
lib/parliament/grom/decorator/answer.rb,
lib/parliament/grom/decorator/gender.rb,
lib/parliament/grom/decorator/person.rb,
lib/parliament/grom/decorator/concept.rb,
lib/parliament/grom/decorator/helpers.rb,
lib/parliament/grom/decorator/version.rb,
lib/parliament/grom/decorator/audience.rb,
lib/parliament/grom/decorator/position.rb,
lib/parliament/grom/decorator/question.rb,
lib/parliament/grom/decorator/procedure.rb,
lib/parliament/grom/decorator/collection.rb,
lib/parliament/grom/decorator/house_seat.rb,
lib/parliament/grom/decorator/incumbency.rb,
lib/parliament/grom/decorator/formal_body.rb,
lib/parliament/grom/decorator/parliaments.rb,
lib/parliament/grom/decorator/web_article.rb,
lib/parliament/grom/decorator/article_type.rb,
lib/parliament/grom/decorator/member_image.rb,
lib/parliament/grom/decorator/work_package.rb,
lib/parliament/grom/decorator/business_item.rb,
lib/parliament/grom/decorator/contact_point.rb,
lib/parliament/grom/decorator/postal_address.rb,
lib/parliament/grom/decorator/procedure_step.rb,
lib/parliament/grom/decorator/european_region.rb,
lib/parliament/grom/decorator/gender_identity.rb,
lib/parliament/grom/decorator/procedure_route.rb,
lib/parliament/grom/decorator/seat_incumbency.rb,
lib/parliament/grom/decorator/formal_body_type.rb,
lib/parliament/grom/decorator/party_membership.rb,
lib/parliament/grom/decorator/constituency_area.rb,
lib/parliament/grom/decorator/formal_body_chair.rb,
lib/parliament/grom/decorator/constituency_group.rb,
lib/parliament/grom/decorator/government_position.rb,
lib/parliament/grom/decorator/helpers/date_helper.rb,
lib/parliament/grom/decorator/opposition_position.rb,
lib/parliament/grom/decorator/government_incumbency.rb,
lib/parliament/grom/decorator/opposition_incumbency.rb,
lib/parliament/grom/decorator/formal_body_membership.rb,
lib/parliament/grom/decorator/work_packageable_thing.rb,
lib/parliament/grom/decorator/parliamentary_incumbency.rb,
lib/parliament/grom/decorator/answering_body_allocation.rb,
lib/parliament/grom/decorator/gov_register_government_organisation.rb

Overview

Namespace for Grom decorators.

Since:

  • 0.1.0

Defined Under Namespace

Modules: Answer, AnsweringBodyAllocation, ArticleType, Audience, BusinessItem, Collection, Concept, ConstituencyArea, ConstituencyGroup, ContactPoint, EuropeanRegion, FormalBody, FormalBodyChair, FormalBodyMembership, FormalBodyType, Gender, GenderIdentity, GovRegisterGovernmentOrganisation, GovernmentIncumbency, GovernmentPosition, Group, Helpers, House, HouseSeat, Incumbency, MemberImage, OppositionIncumbency, OppositionPosition, ParliamentPeriod, ParliamentaryIncumbency, Party, PartyMembership, Person, Position, PostalAddress, Procedure, ProcedureRoute, ProcedureStep, Question, SeatIncumbency, WebArticle, WorkPackage, WorkPackageableThing

Constant Summary collapse

MAPPING =

Since:

  • 0.1.0

{
  'Answer'                            => Answer,
  'AnsweringBodyAllocation'           => AnsweringBodyAllocation,
  'ArticleType'                       => ArticleType,
  'Audience'                          => Audience,
  'BusinessItem'                      => BusinessItem,
  'Collection'                        => Collection,
  'Concept'                           => Concept,
  'ConstituencyArea'                  => ConstituencyArea,
  'ConstituencyGroup'                 => ConstituencyGroup,
  'ContactPoint'                      => ContactPoint,
  'EuropeanRegion'                    => EuropeanRegion,
  'FormalBodyChair'                   => FormalBodyChair,
  'FormalBodyMembership'              => FormalBodyMembership,
  'FormalBodyType'                    => FormalBodyType,
  'FormalBody'                        => FormalBody,
  'Gender'                            => Gender,
  'GenderIdentity'                    => GenderIdentity,
  'GovernmentIncumbency'              => GovernmentIncumbency,
  'GovernmentPosition'                => GovernmentPosition,
  'GovRegisterGovernmentOrganisation' => GovRegisterGovernmentOrganisation,
  'Group'                             => Group,
  'House'                             => House,
  'HouseSeat'                         => HouseSeat,
  'Incumbency'                        => Incumbency,
  'MemberImage'                       => MemberImage,
  'OppositionIncumbency'              => OppositionIncumbency,
  'OppositionPosition'                => OppositionPosition,
  'ParliamentPeriod'                  => ParliamentPeriod,
  'ParliamentaryIncumbency'           => ParliamentaryIncumbency,
  'Party'                             => Party,
  'PartyMembership'                   => PartyMembership,
  'Person'                            => Person,
  'Position'                          => Position,
  'Procedure'                         => Procedure,
  'ProcedureRoute'                    => ProcedureRoute,
  'ProcedureStep'                     => ProcedureStep,
  'PostalAddress'                     => PostalAddress,
  'Question'                          => Question,
  'SeatIncumbency'                    => SeatIncumbency,
  'WebArticle'                        => WebArticle,
  'WorkPackage'                       => WorkPackage,
  'WorkPackageableThing'              => WorkPackageableThing
}.freeze
VERSION =

Since:

  • 0.1.0

'0.27.3'.freeze

Class Method Summary collapse

Class Method Details

.decorate(object) ⇒ Object

Decorates objects with alias methods extended from its decorator module.

Parameters:

  • object (Grom::Node)

    the object to be decorated.

Since:

  • 0.1.0



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/parliament/grom/decorator.rb', line 114

def decorate(object)
  return object unless object.respond_to?(:type)

  Array(object.type).each do |type|
    decorator = MAPPING[::Grom::Helper.get_id(type)] # Get the decorator for a type, or nil

    object.extend(decorator) unless decorator.nil?
  end

  object
end

.gem_pathObject

Gets the root directory of the gem

Since:

  • 0.1.0



101
102
103
# File 'lib/parliament/grom/decorator.rb', line 101

def gem_path
  File.expand_path '../../..', __dir__
end

.load!Object

Since:

  • 0.1.0



105
106
107
108
109
# File 'lib/parliament/grom/decorator.rb', line 105

def load!
  # Loads the translation file into the I18n gem
  I18n.load_path += Dir[File.join(gem_path, 'config', 'locales', '*.yml')]
  I18n.backend.load_translations
end