Class: Lookbook::CustomTag
- Defined in:
- lib/lookbook/tags/custom_tag.rb
Instance Attribute Summary collapse
- #arg_names ⇒ Object readonly
- #tag_args ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(tag_name, text = nil, *args) ⇒ CustomTag
constructor
A new instance of CustomTag.
Methods inherited from YardTag
#options, supports_options, supports_options?, #text, #to_s
Constructor Details
#initialize(tag_name, text = nil, *args) ⇒ CustomTag
Returns a new instance of CustomTag.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lookbook/tags/custom_tag.rb', line 7 def initialize(tag_name, text = nil, *args) tag_definition = Engine..get_tag(tag_name) unless tag_definition raise ParserError.new "Unknown custom tag type '#{tag_name}'" end super(tag_name, text.to_s, *args) @custom_attributes = Store.new @arg_names = tag_definition..fetch(:named_args, []) @after_parse = tag_definition..fetch(:after_parse, nil) validate_arg_names @tag_args = parse_tag @after_parse.call(self) if @after_parse.respond_to?(:call) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object (protected)
49 50 51 52 53 54 55 |
# File 'lib/lookbook/tags/custom_tag.rb', line 49 def method_missing(name, *args) if name.end_with? "=" @custom_attributes[name.to_s.chomp("=")] = args.first else @custom_attributes.public_send(name, *args) || tag_args[name] end end |
Instance Attribute Details
#arg_names ⇒ Object (readonly)
5 6 7 |
# File 'lib/lookbook/tags/custom_tag.rb', line 5 def arg_names @arg_names end |
#tag_args ⇒ Object (readonly)
5 6 7 |
# File 'lib/lookbook/tags/custom_tag.rb', line 5 def tag_args @tag_args end |