Class: JIRA::BaseFactory
- Inherits:
-
Object
- Object
- JIRA::BaseFactory
- Defined in:
- lib/jira/base_factory.rb
Overview
This is the base class for all the JIRA resource factory instances.
Direct Known Subclasses
Resource::AgileFactory, Resource::ApplicationLinkFactory, Resource::AttachmentFactory, Resource::CommentFactory, Resource::ComponentFactory, Resource::CreatemetaFactory, Resource::FieldFactory, Resource::FilterFactory, Resource::IssueFactory, Resource::IssuelinkFactory, Resource::IssuelinktypeFactory, Resource::IssuetypeFactory, Resource::PriorityFactory, Resource::ProjectFactory, Resource::RapidViewFactory, Resource::RemotelinkFactory, Resource::ResolutionFactory, Resource::ServerInfoFactory, Resource::SprintFactory, Resource::StatusFactory, Resource::TransitionFactory, Resource::UserFactory, Resource::VersionFactory, Resource::WebhookFactory, Resource::WorklogFactory
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
-
#build(attrs = {}) ⇒ Object
This method needs special handling as it has a default argument value.
-
#initialize(client) ⇒ BaseFactory
constructor
A new instance of BaseFactory.
-
#target_class ⇒ Object
Return the name of the class which this factory generates, i.e.
Constructor Details
#initialize(client) ⇒ BaseFactory
Returns a new instance of BaseFactory.
8 9 10 |
# File 'lib/jira/base_factory.rb', line 8 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/jira/base_factory.rb', line 6 def client @client end |
Class Method Details
.delegate_to_target_class(*method_names) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/jira/base_factory.rb', line 30 def self.delegate_to_target_class(*method_names) method_names.each do |method_name| define_method method_name do |*args| target_class.send(method_name, @client, *args) end end end |
Instance Method Details
#build(attrs = {}) ⇒ Object
This method needs special handling as it has a default argument value
44 45 46 |
# File 'lib/jira/base_factory.rb', line 44 def build(attrs={}) target_class.build(@client, attrs) end |
#target_class ⇒ Object
Return the name of the class which this factory generates, i.e. JIRA::Resource::FooFactory creates JIRA::Resource::Foo instances.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jira/base_factory.rb', line 14 def target_class # Need to do a little bit of work here as Module.const_get doesn't work # with nested class names, i.e. JIRA::Resource::Foo. # # So create a method chain from the class components. This code will # unroll to: # Module.const_get('JIRA').const_get('Resource').const_get('Foo') # target_class_name = self.class.name.sub(/Factory$/, '') class_components = target_class_name.split('::') class_components.inject(Module) do |mod, const_name| mod.const_get(const_name) end end |