Sha256: 728949fd4ed4a7415ea3464e79fa8a60614300de61568f7a37b64f7d95d2f774
Contents?: true
Size: 1.93 KB
Versions: 2
Compression:
Stored size: 1.93 KB
Contents
require 'vedeu/dsl/composition' require 'vedeu/models/collection' require 'vedeu/presentation/presentation' require 'vedeu/support/common' require 'vedeu/models/view/interfaces' require 'vedeu/models/view/interface' module Vedeu # A composition is a collection of interfaces. # # @api private class Composition include Vedeu::Presentation include Vedeu::Model collection Vedeu::Interfaces member Vedeu::Interface attr_reader :interfaces alias_method :value, :interfaces class << self # @param attributes [Hash] # @option attributes client [] # @option attributes colour [] # @option attributes interfaces [] # @option attributes style [] # @param block [Proc] # @return [Class] def build(attributes = {}, &block) attrs = defaults.merge(attributes) model = new(attrs[:interfaces], attrs[:colour], attrs[:style]) model.deputy(attributes[:client]).instance_eval(&block) if block_given? model end private # The default values for a new instance of this class. # # @return [Hash] def defaults { client: nil, colour: nil, interfaces: [], style: nil, } end end # Returns a new instance of Composition. # # @param interfaces [Interfaces] # @return [Composition] def initialize(interfaces = [], colour = nil, style = nil) @interfaces = interfaces @colour = colour @style = style end # @param child [] # @return [] def add(child) @interfaces = interfaces.add(child) end # Returns log friendly output. # # @return [String] def inspect "<#{self.class.name} (interfaces:#{interfaces.size})>" end # @return [Vedeu::Interfaces] def interfaces collection.coerce(@interfaces, self) end end # Composition end # Vedeu
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.3.2 | lib/vedeu/models/view/composition.rb |
vedeu-0.3.1 | lib/vedeu/models/view/composition.rb |