Class: Hub::Data::Data
- Inherits:
-
Object
- Object
- Hub::Data::Data
- Defined in:
- lib/hub/data.rb
Overview
A convenience wrapper for handling user task related metadata.
Instance Attribute Summary collapse
-
#application_defined ⇒ Object
Returns the value of attribute application_defined.
- #categories ⇒ Array
-
#description ⇒ String
The help description describing this class # TODO- reconcile vs.
-
#hide ⇒ Boolean
True (default) if this task should be linked to from the hub.
-
#klass ⇒ Boolean
The klass of the model.
-
#name ⇒ String?
The class/model name.
- #related_models ⇒ Array
-
#section ⇒ Boolean
The section classification (core, etc.).
-
#shared ⇒ Object
Returns the value of attribute shared.
- #status ⇒ String
Instance Method Summary collapse
- #application_css ⇒ nil, String
- #combined_css ⇒ String
-
#initialize(klass, attributes) ⇒ Data
constructor
A new instance of Data.
- #shared_css ⇒ nil, String
Constructor Details
#initialize(klass, attributes) ⇒ Data
Returns a new instance of Data.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/hub/data.rb', line 43 def initialize(klass, attributes) attributes ||= {} raise "Improperly defined user task #{data} in user_tasks.yml." if klass.nil? @klass = klass.constantize @name = klass.tableize.humanize @description = attributes['description'] @hide = (attributes['hide'] ? true : false) @status = attributes['status'] @categories = attributes['categories'] @section = attributes['section'] @shared = attributes['shared'] @application_defined = attributes['application_defined'] @related_models = attributes['related_models'] end |
Instance Attribute Details
#application_defined ⇒ Object
Returns the value of attribute application_defined.
40 41 42 |
# File 'lib/hub/data.rb', line 40 def application_defined @application_defined end |
#categories ⇒ Array
16 17 18 |
# File 'lib/hub/data.rb', line 16 def categories @categories end |
#description ⇒ String
Returns the help description describing this class # TODO- reconcile vs. model descriptions/documentation elsewhere.
28 29 30 |
# File 'lib/hub/data.rb', line 28 def description @description end |
#hide ⇒ Boolean
Returns true (default) if this task should be linked to from the hub.
20 21 22 |
# File 'lib/hub/data.rb', line 20 def hide @hide end |
#klass ⇒ Boolean
Returns the klass of the model.
36 37 38 |
# File 'lib/hub/data.rb', line 36 def klass @klass end |
#name ⇒ String?
Returns the class/model name.
8 9 10 |
# File 'lib/hub/data.rb', line 8 def name @name end |
#related_models ⇒ Array
32 33 34 |
# File 'lib/hub/data.rb', line 32 def @related_models end |
#section ⇒ Boolean
Returns the section classification (core, etc.).
24 25 26 |
# File 'lib/hub/data.rb', line 24 def section @section end |
#shared ⇒ Object
Returns the value of attribute shared.
38 39 40 |
# File 'lib/hub/data.rb', line 38 def shared @shared end |
#status ⇒ String
12 13 14 |
# File 'lib/hub/data.rb', line 12 def status @status end |
Instance Method Details
#application_css ⇒ nil, String
79 80 81 |
# File 'lib/hub/data.rb', line 79 def application_css application_defined.nil? ? nil : 'application_defined' end |
#combined_css ⇒ String
84 85 86 |
# File 'lib/hub/data.rb', line 84 def combined_css [shared_css, application_css].compact.join(' ') end |
#shared_css ⇒ nil, String
74 75 76 |
# File 'lib/hub/data.rb', line 74 def shared_css shared.nil? ? nil : 'shared' end |