Add the add_property method
Adds support for a public add_property method which exposes adding a property to a Format object dynamically while still doing the right thing with to_hash and to_json.
This commit is contained in:
parent
b81aee29f2
commit
5deb796829
2 changed files with 23 additions and 8 deletions
|
@ -28,12 +28,16 @@ module Microformats2
|
|||
|
||||
def parse_properties
|
||||
PropertyParser.parse(@element.children).each do |property|
|
||||
save_property_name(property.method_name)
|
||||
define_method(property.method_name)
|
||||
set_value(property.method_name, property)
|
||||
add_property(property)
|
||||
end
|
||||
end
|
||||
|
||||
def add_property(property)
|
||||
save_property_name(property.method_name)
|
||||
define_method(property.method_name)
|
||||
set_value(property.method_name, property)
|
||||
end
|
||||
|
||||
def parse_implied_properties
|
||||
ip = []
|
||||
ip << ImpliedProperty::Name.new(@element).parse unless property_present?(:name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue