Class: Docks::Themes::API::Components::Base
- Inherits:
-
Object
- Object
- Docks::Themes::API::Components::Base
show all
- Extended by:
- Forwardable
- Defined in:
- lib/docks_theme_api/components/base_component.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(view, opts = {}, &block) ⇒ Base
30
31
32
33
34
35
|
# File 'lib/docks_theme_api/components/base_component.rb', line 30
def initialize(view, opts = {}, &block)
@view = view
@attributes = opts
@classes = Components.standardize_classes(opts.delete(:classes))
@block = block
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
43
44
45
|
# File 'lib/docks_theme_api/components/base_component.rb', line 43
def method_missing(meth, *args)
@attributes.key?(meth) ? @attributes[meth] : super
end
|
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
26
27
28
|
# File 'lib/docks_theme_api/components/base_component.rb', line 26
def block
@block
end
|
Instance Method Details
#==(other) ⇒ Object
57
58
59
|
# File 'lib/docks_theme_api/components/base_component.rb', line 57
def ==(other)
self.class == other.class && attributes == other.instance_variable_get(:@attributes)
end
|
#classes_for(subcomponent = :base) ⇒ Object
Also known as:
classes
51
52
53
|
# File 'lib/docks_theme_api/components/base_component.rb', line 51
def classes_for(subcomponent = :base)
@classes.fetch(subcomponent, []).join(" ")
end
|
#config {|Config.new(self)| ... } ⇒ Object
Also known as:
configure
37
38
39
|
# File 'lib/docks_theme_api/components/base_component.rb', line 37
def config
yield Config.new(self)
end
|
#inspect ⇒ Object
62
|
# File 'lib/docks_theme_api/components/base_component.rb', line 62
def inspect; to_s end
|
#respond_to?(meth) ⇒ Boolean
47
48
49
|
# File 'lib/docks_theme_api/components/base_component.rb', line 47
def respond_to?(meth)
@attributes.has_key?(meth) || super
end
|
#to_s ⇒ Object
61
|
# File 'lib/docks_theme_api/components/base_component.rb', line 61
def to_s; @attributes.to_s end
|