Class: YFantasy::Transformations::BaseTransform Abstract
- Inherits:
-
Object
- Object
- YFantasy::Transformations::BaseTransform
- Extended by:
- Forwardable
- Defined in:
- lib/y_fantasy/transformations/base_transform.rb
Overview
Subclasses must set @function instance variable
Base class for all transformations in the YFantasy module.
Direct Known Subclasses
CollectionTransformer, DefaultTransformer, Game::PositionTypesTransformer, GameTransformer, GroupTransformer, Instantiator, KeyUnwrapper, League::ScoreboardTransformer, League::SettingsTransformer, League::StandingsTransformer, LeagueTransformer, MatchupsTransformer, PickemTeam::WeekPicksTransformer, PickemTeamTransformer, Player::OwnershipPercentageTransformer, Player::StatsTransformer, PlayerTransformer, StatCategoriesTransformer, StatModifiersTransformer, Team::ManagerTransformer, Team::RosterTransformer, Team::StandingsTransformer, Team::StatsTransformer, TeamTransformer, UserTransformer
Instance Method Summary collapse
-
#>>(other) ⇒ Proc
Function composition - chains this transformation with another.
-
#[](*args) ⇒ Object
Alias for call.
-
#call(*args) ⇒ Object
Invokes the transformation function.
-
#ensure_function_set ⇒ nil
Ensures that the transformation function is properly set.
-
#initialize(*args) ⇒ BaseTransform
constructor
Initializes a new transformation instance.
-
#t(*args) ⇒ Object
Helper method to call transformations provided by Dry::Transformer (see T module).
Constructor Details
#initialize(*args) ⇒ BaseTransform
Initializes a new transformation instance
41 42 43 |
# File 'lib/y_fantasy/transformations/base_transform.rb', line 41 def initialize(*args) ensure_function_set end |
Instance Method Details
#>>(other) ⇒ Proc
Function composition - chains this transformation with another
36 |
# File 'lib/y_fantasy/transformations/base_transform.rb', line 36 def_delegators :@function, :>>, :call, :[] |
#[](*args) ⇒ Object
Alias for call
36 |
# File 'lib/y_fantasy/transformations/base_transform.rb', line 36 def_delegators :@function, :>>, :call, :[] |
#call(*args) ⇒ Object
Invokes the transformation function
36 |
# File 'lib/y_fantasy/transformations/base_transform.rb', line 36 def_delegators :@function, :>>, :call, :[] |
#ensure_function_set ⇒ nil
Ensures that the transformation function is properly set
55 56 57 58 59 |
# File 'lib/y_fantasy/transformations/base_transform.rb', line 55 def ensure_function_set return if @function.respond_to?(:>>) && @function.respond_to?(:call) raise "Subclass must set @function instance variable" end |
#t(*args) ⇒ Object
Helper method to call transformations provided by Dry::Transformer (see T module)
48 49 50 |
# File 'lib/y_fantasy/transformations/base_transform.rb', line 48 def t(*args) T[*args] end |