Class: Phlexi::Field::Theme
- Inherits:
-
Object
- Object
- Phlexi::Field::Theme
- Defined in:
- lib/phlexi/field/theme.rb
Class Method Summary collapse
- .inherited(subclass) ⇒ Object
-
.theme ⇒ Hash
Retrieves the theme hash.
Instance Method Summary collapse
-
#resolve_theme(property, visited = Set.new) ⇒ String?
Recursively resolves the theme for a given property, handling nested symbol references.
- #theme ⇒ Object
Class Method Details
.inherited(subclass) ⇒ Object
6 7 8 9 |
# File 'lib/phlexi/field/theme.rb', line 6 def self.inherited(subclass) super subclass.extend Fiber::Local end |
.theme ⇒ Hash
Retrieves the theme hash
This method returns a hash containing theme definitions for various display components. If a theme has been explicitly set in the options, it returns that. Otherwise, it initializes and returns a default theme.
The theme hash defines CSS classes or references to other theme keys for different components, allowing for a flexible and inheritance-based theming system.
28 29 30 |
# File 'lib/phlexi/field/theme.rb', line 28 def self.theme raise NotImplementedError, "#{self} must implement #self.theme" end |
Instance Method Details
#resolve_theme(property, visited = Set.new) ⇒ String?
Recursively resolves the theme for a given property, handling nested symbol references
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/phlexi/field/theme.rb', line 51 def resolve_theme(property, visited = Set.new) return nil if !property.present? || visited.include?(property) visited.add(property) result = theme[property] if result.is_a?(Symbol) resolve_theme(result, visited) else result end end |
#theme ⇒ Object
32 33 34 |
# File 'lib/phlexi/field/theme.rb', line 32 def theme @theme ||= self.class.theme.freeze end |