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/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/contact_point.rb,
lib/parliament/grom/decorator/postal_address.rb,
lib/parliament/grom/decorator/european_region.rb,
lib/parliament/grom/decorator/gender_identity.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/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, 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, Question, SeatIncumbency, WebArticle

Constant Summary collapse

MAPPING =

Since:

  • 0.1.0

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

Since:

  • 0.1.0

'0.27.0'.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



102
103
104
105
106
107
108
109
110
111
112
# File 'lib/parliament/grom/decorator.rb', line 102

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



89
90
91
# File 'lib/parliament/grom/decorator.rb', line 89

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

.load!Object

Since:

  • 0.1.0



93
94
95
96
97
# File 'lib/parliament/grom/decorator.rb', line 93

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