Sha256: c7069ef27a4338f55b55ada90d38cc56271552d7e768788ce75df93c96c809a6

Contents?: true

Size: 569 Bytes

Versions: 6

Compression:

Stored size: 569 Bytes

Contents

module Styleus
  class ViewComponent < Styleus::Base
    with_attributes :headline, :partial_path, :helper

    # id is used as anchor id in the anchor menu,
    # so it has to be a uid.
    # TODO: make sure the uid-ness :)
    def id
      headline.underscore.gsub(/ /, '_')
    end

    def helper?
      !!helper
    end

    class << self
      def components
        @components ||= []
      end

      def from_hashes(hashes)
        components.clear
        hashes.each { |comp_hash| components << new(comp_hash) }
        components
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
styleus-0.0.10 app/models/styleus/view_component.rb
styleus-0.0.9 app/models/styleus/view_component.rb
styleus-0.0.8 app/models/styleus/view_component.rb
styleus-0.0.7 app/models/styleus/view_component.rb
styleus-0.0.6 app/models/styleus/view_component.rb
styleus-0.0.5 app/models/styleus/view_component.rb