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

#initialize(klass, attributes) ⇒ Data

Returns a new instance of Data.

Parameters:

  • args (Hash)


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_definedObject

Returns the value of attribute application_defined.



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

def application_defined
  @application_defined
end

#categoriesArray

Returns:

  • (Array)


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

def categories
  @categories
end

#descriptionString

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

#hideBoolean

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

#klassBoolean

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

#nameString?

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:

  • (Array)


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

def related_models
  @related_models
end

#sectionBoolean

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

#sharedObject

Returns the value of attribute shared.



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

def shared
  @shared
end

#statusString

Returns:

  • (String)


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

def status
  @status
end

Instance Method Details

#application_cssnil, String

Returns:

  • (nil, String)


79
80
81
# File 'lib/hub/data.rb', line 79

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

#combined_cssString

Returns:

  • (String)


84
85
86
# File 'lib/hub/data.rb', line 84

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

#shared_cssnil, String

Returns:

  • (nil, String)


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

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