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::BoardConfigurationFactory, Resource::BoardFactory, Resource::CommentFactory, Resource::ComponentFactory, Resource::CreatemetaFactory, Resource::FieldFactory, Resource::FilterFactory, Resource::IssueFactory, Resource::IssuePickerSuggestionsFactory, Resource::IssuePickerSuggestionsIssueFactory, Resource::IssuelinkFactory, Resource::IssuelinktypeFactory, Resource::IssuetypeFactory, Resource::PriorityFactory, Resource::ProjectFactory, Resource::RapidViewFactory, Resource::RemotelinkFactory, Resource::ResolutionFactory, Resource::ServerInfoFactory, Resource::SprintFactory, Resource::SprintReportFactory, Resource::StatusFactory, Resource::SuggestedIssueFactory, Resource::TransitionFactory, Resource::UserFactory, Resource::VersionFactory, Resource::WatcherFactory, 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.
6 7 8 |
# File 'lib/jira/base_factory.rb', line 6 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/jira/base_factory.rb', line 4 def client @client end |
Class Method Details
.delegate_to_target_class(*method_names) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/jira/base_factory.rb', line 28 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
42 43 44 |
# File 'lib/jira/base_factory.rb', line 42 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.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jira/base_factory.rb', line 12 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 |