Class: Shaf::Yard::ResourceObject

Inherits:
YARD::CodeObjects::ClassObject
  • Object
show all
Defined in:
lib/shaf/yard/resource_object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#profileObject

Returns the value of attribute profile.



6
7
8
# File 'lib/shaf/yard/resource_object.rb', line 6

def profile
  @profile
end

Class Method Details

.path(*args, sep: '::') ⇒ Object



8
9
10
# File 'lib/shaf/yard/resource_object.rb', line 8

def self.path(*args, sep: '::')
  ['Serializers', *args].join(sep)
end

Instance Method Details

#attributesObject



16
17
18
19
# File 'lib/shaf/yard/resource_object.rb', line 16

def attributes
  children.select { |child| child.type == :attribute }
          .sort_by(&:name)
end

#descriptionObject



49
50
51
52
# File 'lib/shaf/yard/resource_object.rb', line 49

def description
  # TODO: How to add description? @description tag in serializer?
  ''
end


21
22
23
24
# File 'lib/shaf/yard/resource_object.rb', line 21

def links
  children.select { |child| child.type == :link }
          .sort_by(&:name)
end

#pathObject



12
13
14
# File 'lib/shaf/yard/resource_object.rb', line 12

def path
  self.class.path(super, sep: sep)
end

#profile?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/shaf/yard/resource_object.rb', line 35

def profile?
  !!profile
end

#profile_nameObject



39
40
41
42
43
# File 'lib/shaf/yard/resource_object.rb', line 39

def profile_name
  return '' unless profile?

  profile.name
end

#profile_objectsObject



45
46
47
# File 'lib/shaf/yard/resource_object.rb', line 45

def profile_objects
  @profile_objects ||= []
end

#resource_nameObject



26
27
28
29
30
31
32
33
# File 'lib/shaf/yard/resource_object.rb', line 26

def resource_name
  str = name.to_s.sub(/_?serializer$/i, '')
  return str unless str.match? '_'

  str.split('_')
     .map(&:capitalize)
     .join
end