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

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

- (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:

  • (Array)


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:

  • (Array)


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:

  • (String)


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

def status
  @status
end

Instance Method Details

- (nil, String) application_css

Returns:

  • (nil, String)


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

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

- (String) combined_css

Returns:

  • (String)


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

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

- (nil, String) shared_css

Returns:

  • (nil, String)


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

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