Class: CompEx::ComponentDescriptor
- Inherits:
-
Object
- Object
- CompEx::ComponentDescriptor
- Defined in:
- lib/compex/component_descriptor.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#css ⇒ Object
readonly
Returns the value of attribute css.
-
#css_hash ⇒ Object
readonly
Returns the value of attribute css_hash.
-
#css_prefix ⇒ Object
readonly
Returns the value of attribute css_prefix.
-
#exposed ⇒ Object
readonly
Returns the value of attribute exposed.
-
#raw_html ⇒ Object
writeonly
Sets the attribute raw_html.
-
#raw_js ⇒ Object
writeonly
Sets the attribute raw_js.
-
#raw_style ⇒ Object
Returns the value of attribute raw_style.
Instance Method Summary collapse
- #dynamically_defined? ⇒ Boolean
- #has_js? ⇒ Boolean
- #has_style? ⇒ Boolean
- #html ⇒ Object
-
#initialize(parent) ⇒ ComponentDescriptor
constructor
A new instance of ComponentDescriptor.
- #js_class_id ⇒ Object
- #prepare! ⇒ Object
- #required_hashes ⇒ Object
Constructor Details
#initialize(parent) ⇒ ComponentDescriptor
Returns a new instance of ComponentDescriptor.
12 13 14 15 16 17 |
# File 'lib/compex/component_descriptor.rb', line 12 def initialize(parent) @parent = parent @args = Set.new @exposed = Set.new @css_prefix = "cx_#{@parent.component_id}" end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
9 10 11 |
# File 'lib/compex/component_descriptor.rb', line 9 def args @args end |
#css ⇒ Object (readonly)
Returns the value of attribute css.
9 10 11 |
# File 'lib/compex/component_descriptor.rb', line 9 def css @css end |
#css_hash ⇒ Object (readonly)
Returns the value of attribute css_hash.
9 10 11 |
# File 'lib/compex/component_descriptor.rb', line 9 def css_hash @css_hash end |
#css_prefix ⇒ Object (readonly)
Returns the value of attribute css_prefix.
9 10 11 |
# File 'lib/compex/component_descriptor.rb', line 9 def css_prefix @css_prefix end |
#exposed ⇒ Object (readonly)
Returns the value of attribute exposed.
9 10 11 |
# File 'lib/compex/component_descriptor.rb', line 9 def exposed @exposed end |
#raw_html=(value) ⇒ Object (writeonly)
Sets the attribute raw_html
10 11 12 |
# File 'lib/compex/component_descriptor.rb', line 10 def raw_html=(value) @raw_html = value end |
#raw_js=(value) ⇒ Object (writeonly)
Sets the attribute raw_js
10 11 12 |
# File 'lib/compex/component_descriptor.rb', line 10 def raw_js=(value) @raw_js = value end |
#raw_style ⇒ Object
Returns the value of attribute raw_style.
8 9 10 |
# File 'lib/compex/component_descriptor.rb', line 8 def raw_style @raw_style end |
Instance Method Details
#dynamically_defined? ⇒ Boolean
55 56 57 |
# File 'lib/compex/component_descriptor.rb', line 55 def dynamically_defined? @dynamically_defined ||= @parent.name.include?("#") end |
#has_js? ⇒ Boolean
24 |
# File 'lib/compex/component_descriptor.rb', line 24 def has_js? = !@js.nil? |
#has_style? ⇒ Boolean
25 |
# File 'lib/compex/component_descriptor.rb', line 25 def has_style? = !@css.nil? |
#html ⇒ Object
19 20 21 22 |
# File 'lib/compex/component_descriptor.rb', line 19 def html prepare! @html end |
#js_class_id ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/compex/component_descriptor.rb', line 46 def js_class_id return @js_class_id if @js_class_id id = @parent.name.split("::") .reject { it.start_with?("#") } .map(&:hashed).join @js_class_id = "CompEx_#{id}_#{@parent.component_id.upcase}" end |
#prepare! ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/compex/component_descriptor.rb', line 27 def prepare! return if @prepared # prime cached templates js_template css_template prepare_html prepare_js prepare_css update_html_attrs @prepared = true end |
#required_hashes ⇒ Object
42 43 44 |
# File 'lib/compex/component_descriptor.rb', line 42 def required_hashes [@css_hash, @js_hash].compact end |