Class: IssueDrop

Inherits:
BaseDrop
  • Object
show all
Defined in:
app/drops/issue_drop.rb

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See doc/COPYRIGHT.rdoc for more details. ++

Instance Method Summary collapse

Methods inherited from BaseDrop

allowed_methods, #initialize

Constructor Details

This class inherits a constructor from BaseDrop

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object

Allows accessing custom fields by their name:

  • issue.the_name_of_player => CustomField(:name => “The name Of Player”)



65
66
67
68
69
70
71
# File 'app/drops/issue_drop.rb', line 65

def method_missing(method_sym, *arguments, &block)
  if custom_field_with_matching_name = has_custom_field_with_matching_name?(method_sym)
    custom_field(custom_field_with_matching_name.name)
  else
    super
  end
end

Instance Method Details

#before_method(method_sym) ⇒ Object

Allows accessing custom fields by their name:

  • issue.the_name_of_player => CustomField(:name => “The name Of Player”)



53
54
55
56
57
58
59
# File 'app/drops/issue_drop.rb', line 53

def before_method(method_sym)
  if custom_field_with_matching_name = has_custom_field_with_matching_name?(method_sym)
    custom_field(custom_field_with_matching_name.name)
  else
    super
  end
end

#custom_field(name) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'app/drops/issue_drop.rb', line 35

def custom_field(name)
  return '' unless name.present?
  custom_field = IssueCustomField.find_by_name(name.strip)
  return '' unless custom_field.present?
  custom_value = @object.custom_value_for(custom_field)
  if custom_value.present?
    return custom_value.value
  else
    return ''
  end
end