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/laying.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/laid_thing.rb,
lib/parliament/grom/decorator/formal_body.rb,
lib/parliament/grom/decorator/laying_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/answering_body.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/work_packaged_thing.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/statutory_instrument_paper.rb,
lib/parliament/grom/decorator/gov_register_government_organisation.rb,
lib/parliament/grom/decorator/proposed_negative_statutory_instrument_paper.rb
Overview
Namespace for Grom decorators.
Defined Under Namespace
Modules: Answer, AnsweringBody, AnsweringBodyAllocation, ArticleType, Audience, BusinessItem, Collection, Concept, ConstituencyArea, ConstituencyGroup, ContactPoint, EuropeanRegion, FormalBody, FormalBodyChair, FormalBodyMembership, FormalBodyType, Gender, GenderIdentity, GovRegisterGovernmentOrganisation, GovernmentIncumbency, GovernmentPosition, Group, Helpers, House, HouseSeat, Incumbency, LaidThing, Laying, LayingBody, MemberImage, OppositionIncumbency, OppositionPosition, ParliamentPeriod, ParliamentaryIncumbency, Party, PartyMembership, Person, Position, PostalAddress, Procedure, ProcedureRoute, ProcedureStep, ProposedNegativeStatutoryInstrumentPaper, Question, SeatIncumbency, StatutoryInstrumentPaper, WebArticle, WorkPackage, WorkPackageableThing, WorkPackagedThing
Constant Summary collapse
- MAPPING =
{ 'Answer' => Answer, 'AnsweringBody' => AnsweringBody, '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, 'LaidThing' => LaidThing, 'Laying' => , 'LayingBody' => , 'MemberImage' => MemberImage, 'OppositionIncumbency' => OppositionIncumbency, 'OppositionPosition' => OppositionPosition, 'ParliamentPeriod' => ParliamentPeriod, 'ParliamentaryIncumbency' => ParliamentaryIncumbency, 'Party' => Party, 'PartyMembership' => PartyMembership, 'Person' => Person, 'Position' => Position, 'Procedure' => Procedure, 'ProcedureRoute' => ProcedureRoute, 'ProcedureStep' => ProcedureStep, 'ProposedNegativeStatutoryInstrumentPaper' => ProposedNegativeStatutoryInstrumentPaper, 'PostalAddress' => PostalAddress, 'Question' => Question, 'SeatIncumbency' => SeatIncumbency, 'StatutoryInstrumentPaper' => StatutoryInstrumentPaper, 'WebArticle' => WebArticle, 'WorkPackage' => WorkPackage, 'WorkPackageableThing' => WorkPackageableThing, 'WorkPackagedThing' => WorkPackagedThing }.freeze
- VERSION =
'0.29.0'.freeze
Class Method Summary collapse
-
.decorate(object) ⇒ Grom::Node
Decorates objects with alias methods extended from decorator modules.
-
.decorate_with_type(object, type) ⇒ Grom::Node
Decorates objects with alias methods extended from a decorator module.
-
.gem_path ⇒ Object
Gets the root directory of the gem.
- .load! ⇒ Object
Class Method Details
.decorate(object) ⇒ Grom::Node
Decorates objects with alias methods extended from decorator modules. This method reads each of the ‘#type` values and extends the object with a decorator for that type, if available.
131 132 133 134 135 136 137 138 139 |
# File 'lib/parliament/grom/decorator.rb', line 131 def decorate(object) return object unless object.respond_to?(:type) Array(object.type).each do |type| object = decorate_with_type(object, type) end object end |
.decorate_with_type(object, type) ⇒ Grom::Node
Decorates objects with alias methods extended from a decorator module. This method decorated an object with a module matching the type provided.
147 148 149 150 151 152 |
# File 'lib/parliament/grom/decorator.rb', line 147 def decorate_with_type(object, type) decorator = MAPPING[::Grom::Helper.get_id(type)] # Get the decorator for a type, or nil object.extend(decorator) unless decorator.nil? object end |
.gem_path ⇒ Object
Gets the root directory of the gem
115 116 117 |
# File 'lib/parliament/grom/decorator.rb', line 115 def gem_path File. '../../..', __dir__ end |
.load! ⇒ Object
119 120 121 122 123 |
# File 'lib/parliament/grom/decorator.rb', line 119 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 |