Class: Guilded::Component
- Inherits:
-
Object
- Object
- Guilded::Component
- Defined in:
- lib/guilded/component.rb
Instance Attribute Summary collapse
-
#has_javascript ⇒ Object
readonly
Returns the value of attribute has_javascript.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ Component
constructor
A new instance of Component.
- #javascript? ⇒ Boolean
- #javascript_initializer ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Component
Returns a new instance of Component.
12 13 14 15 16 17 18 19 |
# File 'lib/guilded/component.rb', line 12 def initialize( name, ={} ) @name = name @has_javascript = .fetch( :has_javascript, true ) .delete :has_javascript = .stringify_keys end |
Instance Attribute Details
#has_javascript ⇒ Object (readonly)
Returns the value of attribute has_javascript.
8 9 10 |
# File 'lib/guilded/component.rb', line 8 def has_javascript @has_javascript end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/guilded/component.rb', line 8 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/guilded/component.rb', line 8 def end |
Instance Method Details
#javascript? ⇒ Boolean
27 28 29 |
# File 'lib/guilded/component.rb', line 27 def javascript? has_javascript end |
#javascript_initializer ⇒ Object
21 22 23 24 25 |
# File 'lib/guilded/component.rb', line 21 def javascript_initializer javascript? ? "g.init#{name.to_s.camelize}(#{options.to_json});" : "" end |