Module: Weft
- Defined in:
- lib/weft.rb,
lib/weft/page.rb,
lib/weft/error.rb,
lib/weft/action.rb,
lib/weft/router.rb,
lib/weft/context.rb,
lib/weft/version.rb,
lib/weft/redirect.rb,
lib/weft/registry.rb,
lib/weft/resolver.rb,
lib/weft/component.rb,
lib/weft/attributes.rb,
lib/weft/shorthands.rb,
lib/weft/dsl/actions.rb,
lib/weft/dsl/updates.rb,
lib/weft/dsl/triggers.rb,
lib/weft/configuration.rb,
lib/weft/router/errors.rb,
lib/weft/dsl/attributes.rb,
lib/weft/dsl/containers.rb,
lib/weft/dsl/inclusions.rb,
lib/weft/dsl/recoveries.rb,
lib/weft/router/actions.rb,
lib/weft/router/streaming.rb,
lib/weft/defaults/error_page.rb,
lib/weft/router/oob_includes.rb,
lib/weft/context/interception.rb,
lib/weft/registry/eligibility.rb,
lib/weft/defaults/not_found_page.rb,
lib/weft/defaults/error_component.rb,
lib/weft/defaults/not_found_component.rb
Overview
Component-oriented hypermedia for Ruby.
Defined Under Namespace
Modules: DSL, Defaults, Shorthands Classes: Action, Attributes, Component, Configuration, Context, Forbidden, HTTPError, InternalError, NotFound, Page, Redirect, Registry, Resolver, Router, Unauthorized, Unprocessable
Constant Summary collapse
- Error =
Abstract base — never raise directly; use a semantic subclass. Exists for
rescue Weft::Errorto catch the whole gem-error family. Class.new(StandardError)
- InvalidConfiguration =
Raised for semantic mistakes inside
Weft.configure { |c| ... }— values of the right kind that nonetheless violate a constraint (e.g. an asset root not starting with/), or state conflicts (duplicate asset bundles). Class.new(Error)
- InvalidDefinition =
Raised for semantic mistakes in class-body DSL declarations — e.g. a page declares attributes but no
page_path, oradds_children_toreceives a Symbol that does not start with@. Class.new(Error)
- InvalidUsage =
Raised for semantic mistakes at render / action time — invalid input combinations or references to state that isn't there (e.g. an unknown assets bundle named at
register_stylesheet). Class.new(Error)
- MissingContainerIvar =
Raised by the
adds_children_to :@ivarmacro when build returns without ever assigning the named ivar and then a child is added — almost always means the developer declared the macro but forgot the matching assignment. Class.new(InvalidDefinition)
- VERSION =
"0.1.0"
Class Attribute Summary collapse
-
.logger ⇒ Object
Weft's process-wide logger.
Class Method Summary collapse
- .configuration ⇒ Object
- .configure {|configuration| ... } ⇒ Object
-
.redirect(target, **attrs) ⇒ Object
Convenience wrapper for Weft::Redirect.to.
-
.register_shorthand(name, **defaults) ⇒ Object
Register a named interaction shorthand.
- .registry ⇒ Object
-
.shorthand(name) ⇒ Object
Look up a registered shorthand by name.
Class Attribute Details
.logger ⇒ Object
Weft's process-wide logger. In standalone mode this defaults to a $stdout
Logger at the configured log_level (:info by default) — modeling the
unified activity+error stream a 12-factor Rails container emits under
RAILS_LOG_TO_STDOUT, so deployments aggregate it like any other web
container. When mounted in Rails, set Weft.logger = Rails.logger and
this default never applies. Weft.configure applies log_level to it.
42 43 44 |
# File 'lib/weft.rb', line 42 def logger @logger ||= Logger.new($stdout) end |
Class Method Details
.configuration ⇒ Object
46 47 48 |
# File 'lib/weft.rb', line 46 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
54 55 56 57 |
# File 'lib/weft.rb', line 54 def configure yield configuration apply_configuration end |
.redirect(target, **attrs) ⇒ Object
Convenience wrapper for Weft::Redirect.to.
60 61 62 |
# File 'lib/weft.rb', line 60 def redirect(target, **attrs) Redirect.to(target, **attrs) end |
.register_shorthand(name, **defaults) ⇒ Object
Register a named interaction shorthand. Delegates to Weft::Shorthands.
Weft.register_shorthand :tooltip, trigger: :hover, swap: :fill
67 68 69 |
# File 'lib/weft.rb', line 67 def register_shorthand(name, **defaults) Shorthands.register(name, **defaults) end |
.registry ⇒ Object
50 51 52 |
# File 'lib/weft.rb', line 50 def registry @registry ||= Registry.new end |
.shorthand(name) ⇒ Object
Look up a registered shorthand by name. Delegates to Weft::Shorthands.
72 73 74 |
# File 'lib/weft.rb', line 72 def shorthand(name) Shorthands.lookup(name) end |