Class: Hashtags::User

Inherits:
Base
  • Object
show all
Defined in:
lib/hashtags/user.rb

Instance Attribute Summary

Attributes inherited from Base

#str

Class Method Summary collapse

Methods inherited from Base

descendants, json_for_query, json_regexp, match_template, path, resource_classes, strategy, to_hashtag, #to_hashtag, to_markup, #to_markup, user_classes, values, variable_classes

Class Method Details

.cache_keyObject

override for custom cache_key



15
16
17
# File 'lib/hashtags/user.rb', line 15

def self.cache_key
  resource_class.cache_key
end

.help_valuesObject



39
40
41
# File 'lib/hashtags/user.rb', line 39

def self.help_values
  [resource_name]
end

.match_indexObject



50
51
52
# File 'lib/hashtags/user.rb', line 50

def self.match_index
  2
end

.match_regexpObject


JS



46
47
48
# File 'lib/hashtags/user.rb', line 46

def self.match_regexp
  /(#{Regexp.escape(trigger)})(\w{1,})\z/
end

.regexpObject



35
36
37
# File 'lib/hashtags/user.rb', line 35

def self.regexp
  /#{Regexp.escape(trigger)}(\w+)/i
end

.replaceObject



54
55
56
# File 'lib/hashtags/user.rb', line 54

def self.replace
  "#{trigger}{{ #{tag_attribute} }}"
end

.resource_classObject

implement as user class in your application

Raises:

  • (NotImplemented)


6
7
8
# File 'lib/hashtags/user.rb', line 6

def self.resource_class
  raise NotImplemented
end

.resource_nameObject



10
11
12
# File 'lib/hashtags/user.rb', line 10

def self.resource_name
  resource_class.to_s.demodulize.underscore
end

.result_attributeObject

the tags will be replaced by this attribute (for example :full_name)

Raises:

  • (NotImplemented)


31
32
33
# File 'lib/hashtags/user.rb', line 31

def self.result_attribute
  raise NotImplemented
end

.tag_attributeObject

name of attribute to be used in the tag @<tag_attribute> (for example :username)

Raises:

  • (NotImplemented)


25
26
27
# File 'lib/hashtags/user.rb', line 25

def self.tag_attribute
  raise NotImplemented
end

.templateObject



58
59
60
# File 'lib/hashtags/user.rb', line 58

def self.template
  "{{ #{tag_attribute} }}"
end

.triggerObject



19
20
21
# File 'lib/hashtags/user.rb', line 19

def self.trigger
  '@'
end