Module: Labelized::LabelConcern::ClassMethods
- Defined in:
- lib/labelized/label_concern.rb
Instance Method Summary collapse
- #find_or_build_by_list(labels, labeled, label_set_name = nil) ⇒ Object
- #labelized(params = {}) ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#find_or_build_by_list(labels, labeled, label_set_name = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/labelized/label_concern.rb', line 18 def find_or_build_by_list(labels, labeled, label_set_name = nil) label_set_class = ([:label_set_class_name] || 'LabelSet').constantize unless label_set_name.blank? label_set_name.strip! # ooh lah lah label_set = label_set_class.label_scope(labeled).find_or_initialize_by_name(label_set_name) end LabelList.from(labels).map do |label| self.label_scope(labeled).find_or_initialize_by_name_and_label_set_id(label.strip, label_set.id) end end |
#labelized(params = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/labelized/label_concern.rb', line 15 def labelized(params = {}) setup_labelized params def find_or_build_by_list(labels, labeled, label_set_name = nil) label_set_class = ([:label_set_class_name] || 'LabelSet').constantize unless label_set_name.blank? label_set_name.strip! # ooh lah lah label_set = label_set_class.label_scope(labeled).find_or_initialize_by_name(label_set_name) end LabelList.from(labels).map do |label| self.label_scope(labeled).find_or_initialize_by_name_and_label_set_id(label.strip, label_set.id) end end def to_s name end end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/labelized/label_concern.rb', line 31 def to_s name end |