Class: Hashtags::Resource
- Inherits:
-
Base
- Object
- Struct
- Base
- Hashtags::Resource
show all
- Defined in:
- lib/hashtags/resource.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_key ⇒ Object
19
20
21
|
# File 'lib/hashtags/resource.rb', line 19
def self.cache_key
resource_class.cache_key
end
|
.find_by_resource_type(resource_type) ⇒ Object
11
12
13
|
# File 'lib/hashtags/resource.rb', line 11
def self.find_by_resource_type(resource_type)
descendants.detect{ |cls| cls.resource_name.to_s == resource_type.to_s }
end
|
.help_values ⇒ Object
44
45
46
|
# File 'lib/hashtags/resource.rb', line 44
def self.help_values
[resource_name]
end
|
.match_index ⇒ Object
55
56
57
|
# File 'lib/hashtags/resource.rb', line 55
def self.match_index
2
end
|
.match_regexp ⇒ Object
51
52
53
|
# File 'lib/hashtags/resource.rb', line 51
def self.match_regexp
/(#{Regexp.escape(trigger)}#{resource_name}\:)(\w{1,})\z/
end
|
.regexp ⇒ Object
40
41
42
|
# File 'lib/hashtags/resource.rb', line 40
def self.regexp
/#{Regexp.escape(trigger)}#{resource_name}:(.+?)\((.+?)\b\)/i
end
|
.replace ⇒ Object
59
60
61
|
# File 'lib/hashtags/resource.rb', line 59
def self.replace
"#{trigger}#{resource_name}:{{ #{tag_attribute} }}({{ id }})"
end
|
.resource_class ⇒ Object
implement as resource class in your application
7
8
9
|
# File 'lib/hashtags/resource.rb', line 7
def self.resource_class
raise NotImplementedError
end
|
.resource_name ⇒ Object
15
16
17
|
# File 'lib/hashtags/resource.rb', line 15
def self.resource_name
resource_class.to_s.demodulize.underscore
end
|
.result_attribute ⇒ Object
the tags will be replaced by this attribute (for example :link_to)
36
37
38
|
# File 'lib/hashtags/resource.rb', line 36
def self.result_attribute
raise NotImplemented
end
|
.tag_attribute ⇒ Object
name of attribute to be used in the tag #resource_name:<tag_attribute>(id) (for example :to_s)
30
31
32
|
# File 'lib/hashtags/resource.rb', line 30
def self.tag_attribute
raise NotImplemented
end
|
.template ⇒ Object
63
64
65
|
# File 'lib/hashtags/resource.rb', line 63
def self.template
"{{ #{tag_attribute} }}"
end
|
.trigger ⇒ Object
23
24
25
|
# File 'lib/hashtags/resource.rb', line 23
def self.trigger
'#'
end
|