class Typekit::Element::Base
Attributes
attributes[R]
Public Class Methods
feature?(name)
click to toggle source
# File lib/typekit/element/base.rb, line 23 def self.feature?(name) name = Helper.constantize(name) @features ||= {} return @features[name] if @features.key?(name) @features[name] = include?(Element.const_get(name)) end
new(*arguments)
click to toggle source
# File lib/typekit/element/base.rb, line 11 def initialize(*arguments) @attributes = prepare_attributes(Helper.extract_hash!(arguments)) @attributes[:id] = nil unless @attributes.key?(:id) connect(arguments.first) end
Public Instance Methods
assign_attributes(*arguments)
click to toggle source
# File lib/typekit/element/base.rb, line 38 def assign_attributes(*arguments) prepare_attributes(*arguments).each do |name, value| attributes[name] = value end end
attribute?(name)
click to toggle source
# File lib/typekit/element/base.rb, line 34 def attribute?(name) attributes.key?(name) end
become(another)
click to toggle source
# File lib/typekit/element/base.rb, line 17 def become(another) raise ArgumentError, 'Invalid class' unless self.class == another.class @attributes = another.attributes true end
feature?(name)
click to toggle source
# File lib/typekit/element/base.rb, line 30 def feature?(name) self.class.feature?(name) end
Private Instance Methods
method_missing(name, *arguments)
click to toggle source
Calls superclass method
# File lib/typekit/element/base.rb, line 50 def method_missing(name, *arguments) if name.to_s =~ /^(?<name>.*)=$/ name = Regexp.last_match(:name).to_sym attributes.send(:[]=, name, *arguments) else return super unless attributes.key?(name) attributes[name] end end
prepare_attributes(attributes)
click to toggle source
# File lib/typekit/element/base.rb, line 46 def prepare_attributes(attributes) Helper.symbolize_keys(attributes) end