lib/redmine_rest/models/issue.rb in redmine_rest-0.4.0 vs lib/redmine_rest/models/issue.rb in redmine_rest-0.5.0

- old
+ new

@@ -22,10 +22,12 @@ has_one :parent, class_name: Issue has_many :children, class_name: Issue has_many :watchers, class_name: User has_many :relations, class_name: Relation + validates :subject, :tracker_id, presence: true + # # Adds journals, relations, children and watchers to request. # # Be careful, even if issue has watchers, it won't be loaded, # because REST API can load them only after v2.3.0 (see Redmine docs) @@ -41,18 +43,11 @@ end super(what, options) end - # - # Methods for necessery attributes. - # - # I guess it's equal to `.<attribute>?` - # - [:author, :assigned_to, :project, :version, :children, :watchers, :relations, :parent].each do |attr| - define_method(attr) do - attributes[attr] - end + def method_missing(method, *args) + args.empty? && !block_given? ? attributes[method] : super end end end end