Class: Hub::Data::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/hub/data.rb

Overview

A convenience wrapper for handling user task related metadata.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Data) initialize(klass, attributes)

Returns a new instance of Data



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/hub/data.rb', line 42

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

- (Object) application_defined

Returns the value of attribute application_defined



40
41
42
# File 'lib/hub/data.rb', line 40

def application_defined
  @application_defined
end

- (Array) categories

Returns the iconizable categories this task applies to (see yaml)

Returns:

  • (Array)

    the iconizable categories this task applies to (see yaml)



16
17
18
# File 'lib/hub/data.rb', line 16

def categories
  @categories
end

- (String) description

Returns the help description describing this class # TODO- reconcile vs. model descriptions/documentation elsewhere

Returns:

  • (String)

    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

- (Boolean) hide

Returns true (default) if this task should be linked to from the hub

Returns:

  • (Boolean)

    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

- (Boolean) klass

Returns the klass of the model

Returns:

  • (Boolean)

    the klass of the model



36
37
38
# File 'lib/hub/data.rb', line 36

def klass
  @klass
end

- (String?) name

Returns the class/model name

Returns:

  • (String, nil)

    the class/model name



8
9
10
# File 'lib/hub/data.rb', line 8

def name
  @name
end

Returns related (by model name) models

Returns:

  • (Array)

    related (by model name) models



32
33
34
# File 'lib/hub/data.rb', line 32

def related_models
  @related_models
end

- (Boolean) section

Returns the section classification (core, etc.)

Returns:

  • (Boolean)

    the section classification (core, etc.)



24
25
26
# File 'lib/hub/data.rb', line 24

def section
  @section
end

- (Object) shared

Returns the value of attribute shared



38
39
40
# File 'lib/hub/data.rb', line 38

def shared
  @shared
end

- (String) status

Returns one of [complete, stable, prototype, unknown (default) ] (see user_tasks.yml)

Returns:

  • (String)

    one of [complete, stable, prototype, unknown (default) ] (see user_tasks.yml)



12
13
14
# File 'lib/hub/data.rb', line 12

def status
  @status
end

Instance Method Details

- (Object) application_css



73
74
75
# File 'lib/hub/data.rb', line 73

def application_css
  application_defined.nil? ? nil : 'application_defined'
end

- (Object) combined_css



77
78
79
# File 'lib/hub/data.rb', line 77

def combined_css
  [shared_css, application_css].compact.join(" ")
end

- (Object) shared_css



69
70
71
# File 'lib/hub/data.rb', line 69

def shared_css
  shared.nil? ? nil : 'shared'
end